| Index: tools/gn/functions_unittest.cc
|
| diff --git a/tools/gn/functions_unittest.cc b/tools/gn/functions_unittest.cc
|
| index 7156747471225952ae48d78b3b5f4ca8e509449b..949b844b34bc3a9b2ad5eafdd6653ad3802ccb35 100644
|
| --- a/tools/gn/functions_unittest.cc
|
| +++ b/tools/gn/functions_unittest.cc
|
| @@ -125,3 +125,48 @@ TEST(Functions, SplitList) {
|
| "rounding = [[1, 2], [3, 4], [5], [6]]\n",
|
| setup.print_output());
|
| }
|
| +
|
| +TEST(Functions, DeclareArgs) {
|
| + TestWithScope setup;
|
| + Err err;
|
| +
|
| + // It is not legal to read the value of an argument declared in a
|
| + // declare_args() from inside the call, but outside the call and in
|
| + // a separate call should work.
|
| +
|
| + TestParseInput reading_from_same_call(R"(
|
| + declare_args() {
|
| + foo = true
|
| + bar = foo
|
| + })");
|
| + reading_from_same_call.parsed()->Execute(setup.scope(), &err);
|
| + ASSERT_TRUE(err.has_error());
|
| +
|
| + TestParseInput reading_from_outside_call(R"(
|
| + declare_args() {
|
| + foo = true
|
| + }
|
| +
|
| + bar = foo
|
| + assert(bar)
|
| + )");
|
| + err = Err();
|
| + reading_from_outside_call.parsed()->Execute(setup.scope(), &err);
|
| + ASSERT_FALSE(err.has_error());
|
| +
|
| + TestParseInput reading_from_different_call(R"(
|
| + declare_args() {
|
| + foo = true
|
| + }
|
| +
|
| + declare_args() {
|
| + bar = foo
|
| + }
|
| +
|
| + assert(bar)
|
| + )");
|
| + err = Err();
|
| + TestWithScope setup2;
|
| + reading_from_different_call.parsed()->Execute(setup2.scope(), &err);
|
| + ASSERT_FALSE(err.has_error());
|
| +}
|
|
|