diff options
author | Klaus Aehlig <klaus.aehlig@huawei.com> | 2022-05-30 12:38:36 +0200 |
---|---|---|
committer | Klaus Aehlig <klaus.aehlig@huawei.com> | 2022-05-30 15:58:27 +0200 |
commit | f52a182afe3af442ecd8ecf441124a6489f831a3 (patch) | |
tree | d1bb0c0efaa375ac130b425b6750307721b42bf9 /test/buildtool/build_engine/expression/expression.test.cpp | |
parent | 70eed826bc59d924cc3c43ae5f1bc19327493d22 (diff) | |
download | justbuild-f52a182afe3af442ecd8ecf441124a6489f831a3.tar.gz |
Built-in expressions: add enumerate
Add a function transforming a list into a map. In this way, artifacts
collected positionally in a list can easily be realized as a stage
used for input to an action or output of a target.
Diffstat (limited to 'test/buildtool/build_engine/expression/expression.test.cpp')
-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 cbc8c7bf..11ff7a43 100644 --- a/test/buildtool/build_engine/expression/expression.test.cpp +++ b/test/buildtool/build_engine/expression/expression.test.cpp @@ -890,6 +890,24 @@ TEST_CASE("Expression Evaluation", "[expression]") { // NOLINT CHECK(result == Expression::FromJson(R"("esXcXape me XX")"_json)); } + SECTION("enumerate expression") { + auto expr = Expression::FromJson(R"( + { "type": "enumerate" + , "$1": ["foo", "bar", "baz"] + } + )"_json); + REQUIRE(expr); + + auto result = expr.Evaluate(env, fcts); + REQUIRE(result); + CHECK(result == Expression::FromJson(R"( + { "0": "foo" + , "1": "bar" + , "2": "baz" + } + )"_json)); + } + SECTION("keys expression") { auto expr = Expression::FromJson(R"( { "type": "keys" |