summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorKlaus Aehlig <klaus.aehlig@huawei.com>2024-10-22 16:48:03 +0200
committerKlaus Aehlig <klaus.aehlig@huawei.com>2024-10-23 10:11:49 +0200
commit6a1c5cc2c05e7c013a44cddbf030b7d50f1daf12 (patch)
tree9dc0e79829abd5a66819a8bba70680550784fe85 /test
parent4084db065c9bd973ff5664e45336a6674d66b45e (diff)
downloadjustbuild-6a1c5cc2c05e7c013a44cddbf030b7d50f1daf12.tar.gz
expressions: enforce strict arguments for "join" and "join_cmd"v1.4.0-alpha+20241023
... as described in the documentation. It was never intended to have a single string being an argument for those.
Diffstat (limited to 'test')
-rw-r--r--test/buildtool/build_engine/expression/expression.test.cpp15
1 files changed, 10 insertions, 5 deletions
diff --git a/test/buildtool/build_engine/expression/expression.test.cpp b/test/buildtool/build_engine/expression/expression.test.cpp
index aaca1c71..3a34702d 100644
--- a/test/buildtool/build_engine/expression/expression.test.cpp
+++ b/test/buildtool/build_engine/expression/expression.test.cpp
@@ -1042,14 +1042,11 @@ TEST_CASE("Expression Evaluation", "[expression]") { // NOLINT
REQUIRE(multi->IsString());
CHECK(multi == Expression::FromJson(R"("foo;bar;baz")"_json));
+ // only list of strings are allowed
expr = Replace(expr, "$1", foo);
REQUIRE(expr);
- auto string = expr.Evaluate(env, fcts);
- REQUIRE(string);
- REQUIRE(string->IsString());
- CHECK(string == Expression::FromJson(R"("foo")"_json));
+ CHECK_FALSE(expr.Evaluate(env, fcts));
- // only list of strings or string is allowed
expr = Replace(expr, "$1", list_t{foo, ExpressionPtr{number_t{}}});
REQUIRE(expr);
CHECK_FALSE(expr.Evaluate(env, fcts));
@@ -1070,6 +1067,14 @@ TEST_CASE("Expression Evaluation", "[expression]") { // NOLINT
REQUIRE(result->IsString());
CHECK(result ==
Expression::FromJson(R"("'foo' 'bar'\\''s' 'baz'")"_json));
+
+ expr = Expression::FromJson(R"(
+ {"type": "join_cmd"
+ , "$1": "not a list"
+ }
+ )"_json);
+ REQUIRE(expr);
+ CHECK_FALSE(expr.Evaluate(env, fcts));
}
SECTION("escape_chars expression") {