Loading core/product_config.rbc +15 −0 Original line number Diff line number Diff line Loading @@ -676,6 +676,20 @@ def _mkpatsubst(pattern, replacement, s): return out_words if type(s) == "list" else " ".join(out_words) def _mksort(input): """Emulate Make's sort. This is unique from a regular sort in that it also strips the input, and removes duplicate words from the input. """ input = sorted(__words(input)) result = [] for w in input: if len(result) == 0 or result[-1] != w: result.append(w) return result def _mkstrip(s): """Emulates Make's strip. Loading Loading @@ -785,6 +799,7 @@ rblf = struct( mkerror = _mkerror, mkpatsubst = _mkpatsubst, mkwarning = _mkwarning, mksort = _mksort, mkstrip = _mkstrip, mksubst = _mksubst, notdir = _notdir, Loading tests/run.rbc +3 −0 Original line number Diff line number Diff line Loading @@ -32,6 +32,9 @@ def assert_eq(expected, actual): fail("Expected '%s', got '%s'" % (expected, actual)) # Unit tests for non-trivial runtime functions assert_eq(["a", "b", "c"], rblf.mksort("b a c c")) assert_eq(["a", "b", "c"], rblf.mksort(["b", "a", "c", "c"])) assert_eq("", rblf.mkstrip(" \n \t ")) assert_eq("a b c", rblf.mkstrip(" a b \n c \t")) assert_eq(1, rblf.mkstrip(1)) Loading Loading
core/product_config.rbc +15 −0 Original line number Diff line number Diff line Loading @@ -676,6 +676,20 @@ def _mkpatsubst(pattern, replacement, s): return out_words if type(s) == "list" else " ".join(out_words) def _mksort(input): """Emulate Make's sort. This is unique from a regular sort in that it also strips the input, and removes duplicate words from the input. """ input = sorted(__words(input)) result = [] for w in input: if len(result) == 0 or result[-1] != w: result.append(w) return result def _mkstrip(s): """Emulates Make's strip. Loading Loading @@ -785,6 +799,7 @@ rblf = struct( mkerror = _mkerror, mkpatsubst = _mkpatsubst, mkwarning = _mkwarning, mksort = _mksort, mkstrip = _mkstrip, mksubst = _mksubst, notdir = _notdir, Loading
tests/run.rbc +3 −0 Original line number Diff line number Diff line Loading @@ -32,6 +32,9 @@ def assert_eq(expected, actual): fail("Expected '%s', got '%s'" % (expected, actual)) # Unit tests for non-trivial runtime functions assert_eq(["a", "b", "c"], rblf.mksort("b a c c")) assert_eq(["a", "b", "c"], rblf.mksort(["b", "a", "c", "c"])) assert_eq("", rblf.mkstrip(" \n \t ")) assert_eq("a b c", rblf.mkstrip(" a b \n c \t")) assert_eq(1, rblf.mkstrip(1)) Loading