From e3ff4880273746c34d07e641110abaf38a1f1fca Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Tue, 25 Oct 2016 07:46:08 +0200 Subject: Add tests for first_token, second_token testscript lexer modes --- unit-tests/test/script/lexer/driver.cxx | 4 +-- unit-tests/test/script/lexer/first-token.test | 41 ++++++++++++++++++++++++++ unit-tests/test/script/lexer/second-token.test | 37 ++++++++++++++++++++++- 3 files changed, 79 insertions(+), 3 deletions(-) (limited to 'unit-tests') diff --git a/unit-tests/test/script/lexer/driver.cxx b/unit-tests/test/script/lexer/driver.cxx index bda21e4..c5beebb 100644 --- a/unit-tests/test/script/lexer/driver.cxx +++ b/unit-tests/test/script/lexer/driver.cxx @@ -30,8 +30,8 @@ namespace build2 string s (argv[1]); if (s == "script-line") m = lexer_mode::script_line; - else if (s == "first-token") m = lexer_mode::second_token; - else if (s == "second-token") m = lexer_mode::first_token; + else if (s == "first-token") m = lexer_mode::first_token; + 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; diff --git a/unit-tests/test/script/lexer/first-token.test b/unit-tests/test/script/lexer/first-token.test index a665fed..fb75c8b 100644 --- a/unit-tests/test/script/lexer/first-token.test +++ b/unit-tests/test/script/lexer/first-token.test @@ -6,3 +6,44 @@ $* <";" >>EOO # semi-only ; EOO + +$* <"+foo" >>EOO # setup ++ +'foo' + +EOO + +$* <"- foo" >>EOO # tdown +- +'foo' + +EOO + +$* <"foo+bar" >>EOO # plus-leading +'foo+bar' + +EOO + +$* <"foo- x" >>EOO # minus-leading +'foo-' +'x' + +EOO + +$* <"foo=" >>EOO # assign +'foo' +'=' + +EOO + +$* <"foo+=" >>EOO # append +'foo' +'+=' + +EOO + +$* <"foo=+" >>EOO # prepend +'foo' +'=+' + +EOO diff --git a/unit-tests/test/script/lexer/second-token.test b/unit-tests/test/script/lexer/second-token.test index a665fed..cc044dd 100644 --- a/unit-tests/test/script/lexer/second-token.test +++ b/unit-tests/test/script/lexer/second-token.test @@ -1,8 +1,43 @@ # Note: this mode auto-expires after each token. # -test.arguments += first-token +test.arguments += second-token $* <";" >>EOO # semi-only ; EOO + +$* <"=foo" >>EOO # assign += +'foo' + +EOO + +$* <"+= foo" >>EOO # append ++= +'foo' + +EOO + +$* <" =+ foo" >>EOO # prepend +=+ +'foo' + +EOO + +$* <"foo=bar" >>EOO # assign-leading +'foo=bar' + +EOO + +$* <"foo+= bar" >>EOO # append-leading +'foo+=' +'bar' + +EOO + +$* <"foo =+bar" >>EOO # prepend-leading +'foo' +'=+bar' + +EOO -- cgit v1.1