aboutsummaryrefslogtreecommitdiff
path: root/unit-tests/test/script/parser/scope.test
diff options
context:
space:
mode:
authorKaren Arutyunov <karen@codesynthesis.com>2017-01-06 18:46:58 +0300
committerKaren Arutyunov <karen@codesynthesis.com>2017-01-09 21:44:23 +0300
commitc55240fb05151cae046c75a793c164d72c988db2 (patch)
tree35cbba195e0fcc581944b7b098a3ea145741cf94 /unit-tests/test/script/parser/scope.test
parent9e2b4fd3bbc0c61bf6c84540c52869ec7d830718 (diff)
Tests cleanup (take 2)
Diffstat (limited to 'unit-tests/test/script/parser/scope.test')
-rw-r--r--unit-tests/test/script/parser/scope.test410
1 files changed, 234 insertions, 176 deletions
diff --git a/unit-tests/test/script/parser/scope.test b/unit-tests/test/script/parser/scope.test
index 7d78aca..144dc54 100644
--- a/unit-tests/test/script/parser/scope.test
+++ b/unit-tests/test/script/parser/scope.test
@@ -1,5 +1,9 @@
-$* testscript <'cmd $@' >"cmd 1" # id-testscript
-$* foo.test <'cmd $@' >"cmd foo/1" # id
+# file : unit-tests/test/script/parser/scope.test
+# copyright : Copyright (c) 2014-2017 Code Synthesis Ltd
+# license : MIT; see accompanying LICENSE file
+
+$* testscript <'cmd $@' >"cmd 1" : id-testscript
+$* foo.test <'cmd $@' >"cmd foo/1" : id
: wd-testscript
:
@@ -9,214 +13,268 @@ $* testscript <'cmd "$~"' >~"%cmd '?.+[/\\\\]test-driver[/\\\\]1'?%"
:
$* foo.test <'cmd "$~"' >~"%cmd '?.+[/\\\\]test-driver[/\\\\]foo[/\\\\]1'?%"
-$* -s <<EOI # group-empty
-{
-}
-EOI
-
-$* -s <<EOI # group-empty-empty
+: group
+:
{
- {
- }
-}
-EOI
+ : empty
+ :
+ $* -s <<EOI
+ {
+ }
+ EOI
-$* -s <<EOI >>EOO # group
-{
- cmd1
- cmd2
-}
-EOI
-{
+ : empty-empty
+ :
+ $* -s <<EOI
{
{
- cmd1
- }
- {
- cmd2
}
}
-}
-EOO
-
-# Test scope.
-#
+ EOI
-$* -s -i <<EOI >>EOO # test-scope
-{
- cmd
-}
-EOI
-{
- { # 1
- cmd
- }
-}
-EOO
-
-$* -s -i <<EOI >>EOO # test-scope-nested
-{
+ : non-empty
+ :
+ $* -s <<EOI >>EOO
{
- cmd
+ cmd1
+ cmd2
}
-}
-EOI
-{
- { # 1
- cmd
+ EOI
+ {
+ {
+ {
+ cmd1
+ }
+ {
+ cmd2
+ }
+ }
}
+ EOO
}
-EOO
-$* -s -i <<EOI >>EOO # test-scope-var
-{
- x = abc
- cmd $x
-}
-EOI
+: test
+:
{
- { # 1
- cmd abc
- }
-}
-EOO
+ : explicit
+ :
+ {
+ : one-level
+ :
+ $* -s -i <<EOI >>EOO
+ {
+ cmd
+ }
+ EOI
+ {
+ { # 1
+ cmd
+ }
+ }
+ EOO
-$* -s -i <<EOI >>EOO # test-scope-setup
-{
- x = abc
- +setup
- cmd $x
-}
-EOI
-{
- { # 1
- setup
- { # 1/4
- cmd abc
+ : nested
+ :
+ $* -s -i <<EOI >>EOO
+ {
+ {
+ cmd
+ }
}
+ EOI
+ {
+ { # 1
+ cmd
+ }
+ }
+ EOO
+
+ : var
+ :
+ $* -s -i <<EOI >>EOO
+ {
+ x = abc
+ cmd $x
+ }
+ EOI
+ {
+ { # 1
+ cmd abc
+ }
+ }
+ EOO
+
+ : setup
+ :
+ $* -s -i <<EOI >>EOO
+ {
+ x = abc
+ +setup
+ cmd $x
+ }
+ EOI
+ {
+ { # 1
+ setup
+ { # 1/4
+ cmd abc
+ }
+ }
+ }
+ EOO
}
-}
-EOO
+ : implicit
+ {
+ : one-cmd
+ :
+ $* -s <<EOI >>EOO
+ cmd1
+ EOI
+ {
+ {
+ cmd1
+ }
+ }
+ EOO
-#
-#
-$* <:"{x" 2>>EOE != 0 # expected-newline-lcbrace
-testscript:1:2: error: expected newline after '{'
-EOE
+ : two-cmd
+ :
+ $* -s <<EOI >>EOO
+ cmd1;
+ cmd2
+ EOI
+ {
+ {
+ cmd1
+ cmd2
+ }
+ }
+ EOO
-$* <"{" 2>>EOE != 0 # expected-rcbrace
-testscript:2:1: error: expected '}' at the end of the scope
-EOE
+ : three-cmd
+ :
+ $* -s <<EOI >>EOO
+ cmd1;
+ cmd2;
+ cmd3
+ EOI
+ {
+ {
+ cmd1
+ cmd2
+ cmd3
+ }
+ }
+ EOO
-$* <<EOI 2>>EOE != 0 # expected-line-rcbrace
-{
- cmd;
-}
-EOI
-testscript:3:1: error: expected another line after ';'
-EOE
+ : var
+ :
+ $* -s <<EOI >>EOO
+ cmd1;
+ x = abc;
+ cmd2 $x
+ EOI
+ {
+ {
+ cmd1
+ cmd2 abc
+ }
+ }
+ EOO
-$* <<:EOI 2>>EOE != 0 # expected-newline-rcbrace
-{
-}
-EOI
-testscript:2:2: error: expected newline after '}'
-EOE
+ : var-first
+ :
+ $* -s <<EOI >>EOO
+ x = abc;
+ cmd $x
+ EOI
+ {
+ {
+ cmd abc
+ }
+ }
+ EOO
-$* -s <<EOI >>EOO # test-1
-cmd1
-EOI
-{
- {
- cmd1
- }
-}
-EOO
+ : var-setup-tdown
+ :
+ $* -s <<EOI >>EOO
+ x = abc
+ cmd $x
+ y = 123
+ EOI
+ {
+ {
+ cmd abc
+ }
+ }
+ EOO
-$* -s <<EOI >>EOO # test-2
-cmd1;
-cmd2
-EOI
-{
- {
+ : after-tdown
+ :
+ $* <<EOI 2>>EOE != 0
cmd1
+ x = abc
cmd2
+ EOI
+ testscript:3:1: error: test after teardown
+ testscript:2:1: info: last teardown line appears here
+ EOE
}
}
-EOO
-$* -s <<EOI >>EOO # test-3
-cmd1;
-cmd2;
-cmd3
-EOI
+: expected
{
- {
- cmd1
- cmd2
- cmd3
- }
-}
-EOO
+ : newline-lcbrace
+ :
+ $* <:"{x" 2>>EOE != 0
+ testscript:1:2: error: expected newline after '{'
+ EOE
-$* -s <<EOI >>EOO # test-var
-cmd1;
-x = abc;
-cmd2 $x
-EOI
-{
- {
- cmd1
- cmd2 abc
- }
-}
-EOO
+ : rcbrace
+ :
+ $* <"{" 2>>EOE != 0
+ testscript:2:1: error: expected '}' at the end of the scope
+ EOE
-$* -s <<EOI >>EOO # test-var-first
-x = abc;
-cmd $x
-EOI
-{
+ : line-rcbrace
+ :
+ $* <<EOI 2>>EOE != 0
{
- cmd abc
+ cmd;
}
-}
-EOO
+ EOI
+ testscript:3:1: error: expected another line after ';'
+ EOE
-$* -s <<EOI >>EOO # var-setup-tdown
-x = abc
-cmd $x
-y = 123
-EOI
-{
+ : newline-rcbrace
+ :
+ $* <<:EOI 2>>EOE != 0
{
- cmd abc
}
+ EOI
+ testscript:2:2: error: expected newline after '}'
+ EOE
+
+ : line-eof
+ :
+ $* <<EOI 2>>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 <end of file>
+ EOE
+
+ : newline-var
+ :
+ $* <:"x = abc;" 2>>EOE != 0
+ testscript:1:9: error: expected newline instead of <end of file>
+ EOE
}
-EOO
-
-$* <<EOI 2>>EOE != 0 # test-after-tdown
-cmd1
-x = abc
-cmd2
-EOI
-testscript:3:1: error: test after teardown
- testscript:2:1: info: last teardown line appears here
-EOE
-
-$* <<EOI 2>>EOE != 0 # expected-line-eof
-cmd;
-EOI
-testscript:2:1: error: expected another line after ';'
-EOE
-
-$* <<:EOI 2>>EOE != 0 # expected-newline-cmd
-cmd;
-EOI
-testscript:1:5: error: expected newline instead of <end of file>
-EOE
-
-$* <:"x = abc;" 2>>EOE != 0 # expected-newline-var
-testscript:1:9: error: expected newline instead of <end of file>
-EOE