From 757f42e7dea94f8b79b3d55074dedeafd853ddc5 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Fri, 25 Nov 2016 15:17:01 +0200 Subject: Implement literal here-document support --- unit-tests/function/call.test | 42 +++++++++++----------- unit-tests/function/syntax.test | 6 ++-- unit-tests/lexer/comment.test | 24 ++++++------- unit-tests/lexer/quoting.test | 4 +-- unit-tests/test/script/lexer/driver.cxx | 3 +- unit-tests/test/script/parser/command-if.test | 2 +- .../test/script/parser/command-re-parse.test | 4 +-- unit-tests/test/script/parser/description.test | 4 +-- unit-tests/test/script/parser/expansion.test | 2 +- unit-tests/test/script/parser/here-document.test | 10 +++--- unit-tests/test/script/parser/include.test | 4 +-- unit-tests/test/script/parser/scope.test | 10 +++--- 12 files changed, 58 insertions(+), 57 deletions(-) (limited to 'unit-tests') diff --git a/unit-tests/function/call.test b/unit-tests/function/call.test index 396090a..d16b91c 100644 --- a/unit-tests/function/call.test +++ b/unit-tests/function/call.test @@ -13,8 +13,8 @@ $* <'print $dummy.qual()' >'abc' : qual-fail : $* <'print $qual()' 2>>EOE != 0 -buildfile:1:8: error: unmatched call to qual\() - info: candidate: dummy.qual\() +buildfile:1:8: error: unmatched call to qual() + info: candidate: dummy.qual() EOE : derived-base @@ -32,42 +32,42 @@ $* <'print $variadic([bool] true)' >'1' : $* <'$fail()' 2>>EOE != 0 error: failed -buildfile:1:2: info: while calling fail\() +buildfile:1:2: info: while calling fail() EOE : fail-invalid-arg : $* <'$fail_arg(abc)' 2>>EOE != 0 error: invalid argument: invalid uint64 value: 'abc' -buildfile:1:2: info: while calling fail_arg\() +buildfile:1:2: info: while calling fail_arg() EOE : no-match-name : $* <'$bogus()' 2>>EOE != 0 -buildfile:1:2: error: unmatched call to bogus\() +buildfile:1:2: error: unmatched call to bogus() EOE : no-match-count : $* <'$dummy0(abc)' 2>>EOE != 0 -buildfile:1:2: error: unmatched call to dummy0\() - info: candidate: dummy0\(), qualified name dummy.dummy0 +buildfile:1:2: error: unmatched call to dummy0() + info: candidate: dummy0(), qualified name dummy.dummy0 EOE : no-match-type : $* <'$dummy1([uint64] 123)' 2>>EOE != 0 -buildfile:1:2: error: unmatched call to dummy1\(uint64) - info: candidate: dummy1\(string), qualified name dummy.dummy1 +buildfile:1:2: error: unmatched call to dummy1(uint64) + info: candidate: dummy1(string), qualified name dummy.dummy1 EOE : ambig : $* <'$ambig(abc)' 2>- != 0 # @@ REGEX -#buildfile:1:2: error: ambiguous call to ambig\() -# info: candidate: ambig\( [, uint64]), qualified name dummy.ambig -# info: candidate: ambig\( [, string]), qualified name dummy.ambig +#buildfile:1:2: error: ambiguous call to ambig() +# info: candidate: ambig( [, uint64]), qualified name dummy.ambig +# info: candidate: ambig( [, string]), qualified name dummy.ambig #EOE : optional-absent @@ -90,19 +90,19 @@ $* <'print $nullable(nonull)' >'false' : $* <'$dummy1([string null])' 2>>EOE != 0 error: invalid argument: null value -buildfile:1:2: info: while calling dummy1\(string) +buildfile:1:2: info: while calling dummy1(string) EOE : print-call-1-untyped : $* <'$bogus(abc)' 2>>EOE != 0 -buildfile:1:2: error: unmatched call to bogus\() +buildfile:1:2: error: unmatched call to bogus() EOE : print-call-1-typed : $* <'$bogus([uint64] 123)' 2>>EOE != 0 -buildfile:1:2: error: unmatched call to bogus\(uint64) +buildfile:1:2: error: unmatched call to bogus(uint64) EOE #\ @@ -110,23 +110,23 @@ EOE : print-call-2 : $* <'$bogus(abc, [uint64] 123)' 2>>EOE != 0 -buildfile:1:2: error: unmatched call to bogus\(, uint64) +buildfile:1:2: error: unmatched call to bogus(, uint64) EOE #\ : print-fovl : $* <'$ambig([bool] true)' 2>- != 0 # @@ REGEX -#buildfile:1:2: error: unmatched call to ambig\(bool) -# info: candidate: ambig\( [, uint64]), qualified name dummy.ambig -# info: candidate: ambig\( [, string]), qualified name dummy.ambig +#buildfile:1:2: error: unmatched call to ambig(bool) +# info: candidate: ambig( [, uint64]), qualified name dummy.ambig +# info: candidate: ambig( [, string]), qualified name dummy.ambig #EOE : print-fovl-variadic : $* <'$variadic(abc)' 2>>EOE != 0 -buildfile:1:2: error: unmatched call to variadic\() - info: candidate: variadic\(bool [, ...]) +buildfile:1:2: error: unmatched call to variadic() + info: candidate: variadic(bool [, ...]) EOE : member-function diff --git a/unit-tests/function/syntax.test b/unit-tests/function/syntax.test index 9e653c8..d644fd1 100644 --- a/unit-tests/function/syntax.test +++ b/unit-tests/function/syntax.test @@ -19,9 +19,9 @@ $* <>EOO foo = FOO bar = BAR -print \$foo"\(\$bar)" -print "\$foo"\(\$bar) -print "\$foo""\(\$bar)" +print $foo"($bar)" +print "$foo"($bar) +print "$foo""($bar)" EOI FOOBAR FOOBAR diff --git a/unit-tests/lexer/comment.test b/unit-tests/lexer/comment.test index 07d7ac5..65e768c 100644 --- a/unit-tests/lexer/comment.test +++ b/unit-tests/lexer/comment.test @@ -59,34 +59,34 @@ EOO # $* <>:EOO # multi-only -#\\ +#\ comment comment -#\\ +#\ EOI EOO $* <>:EOO # multi-empty -#\\ -#\\ +#\ +#\ EOI EOO $* <>EOO # multi-start-same -foo #\\ +foo #\ comment comment -#\\ +#\ EOI 'foo' EOO $* <>EOO # multi-end-same -#\\ +#\ comment comment -foo #\\ +foo #\ bar EOI 'bar' @@ -94,10 +94,10 @@ EOI EOO $* <>EOO # multi-end-not -#\\ +#\ comment -#\\ not an end -foo #\\ +#\ not an end +foo #\ bar EOI 'bar' @@ -105,7 +105,7 @@ EOI EOO $* <>EOE != 0 # multi-unterm -#\\ +#\ comment EOI stdin:3:1: error: unterminated multi-line comment diff --git a/unit-tests/lexer/quoting.test b/unit-tests/lexer/quoting.test index 76fd904..aab02c3 100644 --- a/unit-tests/lexer/quoting.test +++ b/unit-tests/lexer/quoting.test @@ -48,7 +48,7 @@ EOO : $* <'"$foo"' >>EOO '' [D/P] -\$ +$ 'foo' [D/P] EOO @@ -58,7 +58,7 @@ EOO : $* <'"foo$"' >>EOO 'foo' [D/P] -\$ +$ '' [D/P] EOO diff --git a/unit-tests/test/script/lexer/driver.cxx b/unit-tests/test/script/lexer/driver.cxx index abd32ba..3709191 100644 --- a/unit-tests/test/script/lexer/driver.cxx +++ b/unit-tests/test/script/lexer/driver.cxx @@ -34,7 +34,8 @@ namespace build2 else if (s == "second-token") m = lexer_mode::second_token; else if (s == "variable-line") m = lexer_mode::variable_line; else if (s == "command-line") m = lexer_mode::command_line; - else if (s == "here-line") m = lexer_mode::here_line; + else if (s == "here-line-single") m = lexer_mode::here_line_single; + else if (s == "here-line-double") m = lexer_mode::here_line_double; else if (s == "description-line") m = lexer_mode::description_line; else if (s == "variable") m = lexer_mode::variable; else assert (false); diff --git a/unit-tests/test/script/parser/command-if.test b/unit-tests/test/script/parser/command-if.test index 88cc7d6..4bbc016 100644 --- a/unit-tests/test/script/parser/command-if.test +++ b/unit-tests/test/script/parser/command-if.test @@ -249,7 +249,7 @@ if true else x = bar end; -cmd \$x +cmd $x EOI ? true cmd foo diff --git a/unit-tests/test/script/parser/command-re-parse.test b/unit-tests/test/script/parser/command-re-parse.test index aee4f78..335ff69 100644 --- a/unit-tests/test/script/parser/command-re-parse.test +++ b/unit-tests/test/script/parser/command-re-parse.test @@ -2,8 +2,8 @@ # double-quote # $* <>EOO -x = cmd \\">-\\" "'<-'" -\$x +x = cmd \">-\" "'<-'" +$x EOI cmd '>-' '<-' EOO diff --git a/unit-tests/test/script/parser/description.test b/unit-tests/test/script/parser/description.test index 1b3f358..b4ab435 100644 --- a/unit-tests/test/script/parser/description.test +++ b/unit-tests/test/script/parser/description.test @@ -180,7 +180,7 @@ EOE $* <>EOO # legal-var : foo bar x = y; -cmd \$x +cmd $x EOI : sm:foo bar cmd y @@ -334,7 +334,7 @@ EOO : : No merge since test has description. : -$* -s -i <>EOO # +$* -s -i <>EOO # { : foo-bar : foo bar diff --git a/unit-tests/test/script/parser/expansion.test b/unit-tests/test/script/parser/expansion.test index c23d598..1d10a63 100644 --- a/unit-tests/test/script/parser/expansion.test +++ b/unit-tests/test/script/parser/expansion.test @@ -6,7 +6,7 @@ $* <>EOO x = dir/ proj% proj%name proj%proj%dir/type{name name {name}} cmd dir/ proj% proj%name proj%proj%dir/type{name name {name}} -cmd \$x +cmd $x EOI cmd dir/ proj% proj%name proj%proj%dir/type{name name {name}} cmd dir/ proj% proj%name proj%proj%dir/type{name name {name}} diff --git a/unit-tests/test/script/parser/here-document.test b/unit-tests/test/script/parser/here-document.test index 6f26166..7cb9474 100644 --- a/unit-tests/test/script/parser/here-document.test +++ b/unit-tests/test/script/parser/here-document.test @@ -128,8 +128,8 @@ : $* <>EOO x = foo bar - cmd <>EOO x = foo - cmd <>EOO -cmd <>>foo-$(build.version).test; cmd EOI $* <>EOO -.include foo-\$\(build.version\).test +.include foo-$(build.version).test EOI cmd EOO diff --git a/unit-tests/test/script/parser/scope.test b/unit-tests/test/script/parser/scope.test index 3b10d01..6ddb265 100644 --- a/unit-tests/test/script/parser/scope.test +++ b/unit-tests/test/script/parser/scope.test @@ -74,7 +74,7 @@ EOO $* -s -i <>EOO # test-scope-var { x = abc - cmd \$x + cmd $x } EOI { @@ -88,7 +88,7 @@ $* -s -i <>EOO # test-scope-setup { x = abc +setup - cmd \$x + cmd $x } EOI { @@ -166,7 +166,7 @@ EOO $* -s <>EOO # test-var cmd1; x = abc; -cmd2 \$x +cmd2 $x EOI { { @@ -178,7 +178,7 @@ EOO $* -s <>EOO # test-var-first x = abc; -cmd \$x +cmd $x EOI { { @@ -189,7 +189,7 @@ EOO $* -s <>EOO # var-setup-tdown x = abc -cmd \$x +cmd $x y = 123 EOI { -- cgit v1.1