summaryrefslogtreecommitdiff
path: root/test/buildtool/build_engine/expression/expression.test.cpp
diff options
context:
space:
mode:
authorKlaus Aehlig <klaus.aehlig@huawei.com>2024-08-13 13:13:29 +0200
committerKlaus Aehlig <klaus.aehlig@huawei.com>2024-08-14 15:29:17 +0200
commit7482b4b90b376cc1d1d64ef827d9014879f0ef84 (patch)
treee379fee1064b9dc52b812c4f6b578b1012ebfd77 /test/buildtool/build_engine/expression/expression.test.cpp
parent21359a210cecf01d0c0e3ff47873692bdb1390a9 (diff)
downloadjustbuild-7482b4b90b376cc1d1d64ef827d9014879f0ef84.tar.gz
expression language: add nub_left
Originally, the expression lanuage only contained a function to deduplicate a list, keeping only the right-most occurence. The reason was that this is the order needed for linking: a library providing an open symbol has to come on the command line after the library using that symbol (and hence making it an open symbol). However, by now use cases have emerged that require a topological sorting where definition comes before use; also, when composing the value of PATH from fragments, we usually want to keep the first occurrence in order for it to take precedence. Therefore, also add "nub_left" as built-in function, allowing a more condense (and slightly more efficient) description in rules instead of the revserse-nub_right-reverse pattern.
Diffstat (limited to 'test/buildtool/build_engine/expression/expression.test.cpp')
-rw-r--r--test/buildtool/build_engine/expression/expression.test.cpp13
1 files changed, 13 insertions, 0 deletions
diff --git a/test/buildtool/build_engine/expression/expression.test.cpp b/test/buildtool/build_engine/expression/expression.test.cpp
index 938bd63f..83d6a2fe 100644
--- a/test/buildtool/build_engine/expression/expression.test.cpp
+++ b/test/buildtool/build_engine/expression/expression.test.cpp
@@ -946,6 +946,19 @@ TEST_CASE("Expression Evaluation", "[expression]") { // NOLINT
)"_json));
}
+ SECTION("nub_left expression") {
+ auto expr = Expression::FromJson(R"(
+ {"type": "nub_left"
+ , "$1": ["a", "b", "b", "a", "c", "b", "a"]
+ })"_json);
+ REQUIRE(expr);
+
+ auto result = expr.Evaluate(env, fcts);
+ REQUIRE(result);
+ REQUIRE(result->IsList());
+ CHECK(result == Expression::FromJson(R"(["a", "b", "c"])"_json));
+ }
+
SECTION("change_ending") {
auto expr = Expression::FromJson(R"(
{ "type": "change_ending"