diff options
author | Klaus Aehlig <klaus.aehlig@huawei.com> | 2024-04-23 12:35:39 +0200 |
---|---|---|
committer | Klaus Aehlig <klaus.aehlig@huawei.com> | 2024-04-24 12:30:09 +0200 |
commit | eb085c33aba12a332c3ee8e73d26a241a6996c41 (patch) | |
tree | f0bf5cffd3fd04c64d26c5c4d821deb0bde59114 /test/buildtool/build_engine/expression/expression.test.cpp | |
parent | 14b93071eca21c69b635bd77eb68057b2906ddab (diff) | |
download | justbuild-eb085c33aba12a332c3ee8e73d26a241a6996c41.tar.gz |
expressions: for "if" expressions, make both branches optional
... using, also for the "then" branch, the empty list as default.
In this way, this statement not only more symmetric, but also
allows shorter representations of some typical expressions.
Diffstat (limited to 'test/buildtool/build_engine/expression/expression.test.cpp')
-rw-r--r-- | test/buildtool/build_engine/expression/expression.test.cpp | 13 |
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 83550ebd..1d7bde3e 100644 --- a/test/buildtool/build_engine/expression/expression.test.cpp +++ b/test/buildtool/build_engine/expression/expression.test.cpp @@ -479,6 +479,19 @@ TEST_CASE("Expression Evaluation", "[expression]") { // NOLINT CHECK(failure == Expression::FromJson(R"("failure")"_json)); } } + + SECTION("if defaults") { + auto expr = Expression::FromJson(R"( + { "type": "if" + , "cond": {"type": "var", "name": "x"} + } + )"_json); + CHECK(expr.Evaluate(env.Update("x", true), fcts) == + Expression::FromJson(R"([])"_json)); + CHECK(expr.Evaluate(env.Update("x", false), fcts) == + Expression::FromJson(R"([])"_json)); + } + SECTION("cond expression") { auto expr = Expression::FromJson(R"( { "type": "cond" |