diff options
author | Klaus Aehlig <klaus.aehlig@huawei.com> | 2023-08-14 11:43:28 +0200 |
---|---|---|
committer | Klaus Aehlig <klaus.aehlig@huawei.com> | 2023-08-14 12:09:57 +0200 |
commit | 726e70cb9bf544ee3164e32405e4dd4f750c0403 (patch) | |
tree | 7e15485967af5f24852e30d54059b62a40e8928d /test | |
parent | 755360ab129879c8981c84262ef1f1d3e697a5e0 (diff) | |
download | justbuild-726e70cb9bf544ee3164e32405e4dd4f750c0403.tar.gz |
expression: add new built in "set"
... to obtain from a list of strings a map with those entries
as keys and true as value. In this way, repeated membership tests
in lists can be implemented more efficiently.
Diffstat (limited to 'test')
-rw-r--r-- | test/buildtool/build_engine/expression/expression.test.cpp | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/test/buildtool/build_engine/expression/expression.test.cpp b/test/buildtool/build_engine/expression/expression.test.cpp index 10edbcbd..7f3df7c5 100644 --- a/test/buildtool/build_engine/expression/expression.test.cpp +++ b/test/buildtool/build_engine/expression/expression.test.cpp @@ -924,6 +924,24 @@ TEST_CASE("Expression Evaluation", "[expression]") { // NOLINT )"_json)); } + SECTION("set expression") { + auto expr = Expression::FromJson(R"( + { "type": "set" + , "$1": ["foo", "bar", "baz"] + } + )"_json); + REQUIRE(expr); + + auto result = expr.Evaluate(env, fcts); + REQUIRE(result); + CHECK(result == Expression::FromJson(R"( + { "foo": true + , "bar": true + , "baz": true + } + )"_json)); + } + SECTION("keys expression") { auto expr = Expression::FromJson(R"( { "type": "keys" |