From f52a182afe3af442ecd8ecf441124a6489f831a3 Mon Sep 17 00:00:00 2001 From: Klaus Aehlig Date: Mon, 30 May 2022 12:38:36 +0200 Subject: 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. --- .../build_engine/expression/expression.test.cpp | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'test/buildtool/build_engine/expression/expression.test.cpp') 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" -- cgit v1.2.3