From 5007870b52aa549971824959a55ad3bb886f09e0 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Mon, 3 Sep 2018 16:37:32 +0200 Subject: Rename .test/test{} to .testscript/testscript{} --- unit-tests/test/script/parser/scope.testscript | 280 +++++++++++++++++++++++++ 1 file changed, 280 insertions(+) create mode 100644 unit-tests/test/script/parser/scope.testscript (limited to 'unit-tests/test/script/parser/scope.testscript') diff --git a/unit-tests/test/script/parser/scope.testscript b/unit-tests/test/script/parser/scope.testscript new file mode 100644 index 0000000..721e455 --- /dev/null +++ b/unit-tests/test/script/parser/scope.testscript @@ -0,0 +1,280 @@ +# file : unit-tests/test/script/parser/scope.testscript +# copyright : Copyright (c) 2014-2018 Code Synthesis Ltd +# license : MIT; see accompanying LICENSE file + +$* testscript <'cmd $@' >"cmd 1" : id-testscript +$* foo.testscript <'cmd $@' >"cmd foo/1" : id + +: wd-testscript +: +$* testscript <'cmd "$~"' >~"%cmd '?.+[/\\\\]test-driver[/\\\\]1'?%" + +: wd +: +$* foo.testscript <'cmd "$~"' >~"%cmd '?.+[/\\\\]test-driver[/\\\\]foo[/\\\\]1'?%" + +: group +: +{ + : empty + : + $* -s <>EOO + { + cmd1 + cmd2 + } + EOI + { + { + { + cmd1 + } + { + cmd2 + } + } + } + EOO +} + +: test +: +{ + : explicit + : + { + : one-level + : + $* -s -i <>EOO + { + cmd + } + EOI + { + { # 1 + cmd + } + } + EOO + + : nested + : + $* -s -i <>EOO + { + { + cmd + } + } + EOI + { + { # 1 + cmd + } + } + EOO + + : var + : + $* -s -i <>EOO + { + x = abc + cmd $x + } + EOI + { + { # 1 + cmd abc + } + } + EOO + + : setup + : + $* -s -i <>EOO + { + x = abc + +setup + cmd $x + } + EOI + { + { # 1 + +setup + { # 1/4 + cmd abc + } + } + } + EOO + } + + : implicit + { + : one-cmd + : + $* -s <>EOO + cmd1 + EOI + { + { + cmd1 + } + } + EOO + + : two-cmd + : + $* -s <>EOO + cmd1; + cmd2 + EOI + { + { + cmd1 + cmd2 + } + } + EOO + + : three-cmd + : + $* -s <>EOO + cmd1; + cmd2; + cmd3 + EOI + { + { + cmd1 + cmd2 + cmd3 + } + } + EOO + + : var + : + $* -s <>EOO + cmd1; + x = abc; + cmd2 $x + EOI + { + { + cmd1 + cmd2 abc + } + } + EOO + + : var-first + : + $* -s <>EOO + x = abc; + cmd $x + EOI + { + { + cmd abc + } + } + EOO + + : var-setup-tdown + : + $* -s <>EOO + x = abc + cmd $x + y = 123 + EOI + { + { + cmd abc + } + } + EOO + + : after-tdown + : + $* <>EOE != 0 + cmd1 + x = abc + cmd2 + EOI + testscript:3:1: error: test after teardown + testscript:2:1: info: last teardown line appears here + EOE + } +} + +: expected +{ + : newline-lcbrace + : + $* <:"{x" 2>>EOE != 0 + testscript:1:2: error: expected newline after '{' + EOE + + : rcbrace + : + $* <"{" 2>>EOE != 0 + testscript:2:1: error: expected '}' at the end of the scope + EOE + + : line-rcbrace + : + $* <>EOE != 0 + { + cmd; + } + EOI + testscript:3:1: error: expected another line after ';' + EOE + + : newline-rcbrace + : + $* <<:EOI 2>>EOE != 0 + { + } + EOI + testscript:2:2: error: expected newline after '}' + EOE + + : line-eof + : + $* <>EOE != 0 + cmd; + EOI + testscript:2:1: error: expected another line after ';' + EOE + + : newline-cmd + : + $* <<:EOI 2>>EOE != 0 + cmd; + EOI + testscript:1:5: error: expected newline instead of + EOE + + : newline-var + : + $* <:"x = abc;" 2>>EOE != 0 + testscript:1:9: error: expected newline instead of + EOE +} -- cgit v1.1