aboutsummaryrefslogtreecommitdiff
path: root/unit-tests/test/script/parser/command-if.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/command-if.test
parent9e2b4fd3bbc0c61bf6c84540c52869ec7d830718 (diff)
Tests cleanup (take 2)
Diffstat (limited to 'unit-tests/test/script/parser/command-if.test')
-rw-r--r--unit-tests/test/script/parser/command-if.test891
1 files changed, 460 insertions, 431 deletions
diff --git a/unit-tests/test/script/parser/command-if.test b/unit-tests/test/script/parser/command-if.test
index 4bbc016..ffe2c35 100644
--- a/unit-tests/test/script/parser/command-if.test
+++ b/unit-tests/test/script/parser/command-if.test
@@ -1,225 +1,506 @@
-: if-true
-:
-$* <<EOI >>EOO
-if true foo
- cmd1
- cmd2
-end
-EOI
-? true foo
-cmd1
-cmd2
-EOO
+# file : unit-tests/test/script/parser/command-if.test
+# copyright : Copyright (c) 2014-2017 Code Synthesis Ltd
+# license : MIT; see accompanying LICENSE file
-: if-false
+: if
:
-$* <<EOI >>EOO
-if false foo
+{
+ : true
+ :
+ $* <<EOI >>EOO
+ if true foo
+ cmd1
+ cmd2
+ end
+ EOI
+ ? true foo
cmd1
cmd2
-end
-EOI
-? false foo
-EOO
+ EOO
-: ifn-true
-:
-$* <<EOI >>EOO
-if! true foo
+ : false
+ :
+ $* <<EOI >>EOO
+ if false foo
+ cmd1
+ cmd2
+ end
+ EOI
+ ? false foo
+ EOO
+
+ : not-true
+ :
+ $* <<EOI >>EOO
+ if! true foo
+ cmd1
+ cmd2
+ end
+ EOI
+ ? true foo
+ EOO
+
+ : not-false
+ :
+ $* <<EOI >>EOO
+ if! false foo
+ cmd1
+ cmd2
+ end
+ EOI
+ ? false foo
cmd1
cmd2
-end
-EOI
-? true foo
-EOO
+ EOO
-: ifn-false
-:
-$* <<EOI >>EOO
-if! false foo
- cmd1
- cmd2
-end
-EOI
-? false foo
-cmd1
-cmd2
-EOO
+ : without-command
+ :
+ $* <<EOI 2>>EOE != 0
+ if
+ cmd
+ end
+ EOI
+ testscript:1:3: error: missing program
+ EOE
+
+ : after-semi
+ :
+ $* -s <<EOI >>EOO
+ cmd1;
+ if true
+ cmd2
+ end
+ EOI
+ {
+ {
+ cmd1
+ ? true
+ cmd2
+ }
+ }
+ EOO
-: elif-true
-:
-$* <<EOI >>EOO
-if false
- cmd1
- cmd2
-elif true
- cmd3
- cmd4
-end
-EOI
-? false
-? true
-cmd3
-cmd4
-EOO
+ : setup
+ :
+ $* -s <<EOI >>EOO
+ +if true
+ cmd
+ end
+ EOI
+ {
+ ? true
+ cmd
+ }
+ EOO
-: elif-false
-:
-$* <<EOI >>EOO
-if false
- cmd1
- cmd2
-elif false
- cmd3
- cmd4
-end
-EOI
-? false
-? false
-EOO
+ : tdown
+ :
+ $* -s <<EOI >>EOO
+ -if true
+ cmd
+ end
+ EOI
+ {
+ ? true
+ cmd
+ }
+ EOO
+}
-: elifn-true
+: elif
:
-$* <<EOI >>EOO
-if false
- cmd1
- cmd2
-elif! true
+{
+ : true
+ :
+ $* <<EOI >>EOO
+ if false
+ cmd1
+ cmd2
+ elif true
+ cmd3
+ cmd4
+ end
+ EOI
+ ? false
+ ? true
cmd3
cmd4
-end
-EOI
-? false
-? true
-EOO
+ EOO
-: elifn-false
-:
-$* <<EOI >>EOO
-if false
- cmd1
- cmd2
-elif! false
+ : false
+ :
+ $* <<EOI >>EOO
+ if false
+ cmd1
+ cmd2
+ elif false
+ cmd3
+ cmd4
+ end
+ EOI
+ ? false
+ ? false
+ EOO
+
+ : not-true
+ :
+ $* <<EOI >>EOO
+ if false
+ cmd1
+ cmd2
+ elif! true
+ cmd3
+ cmd4
+ end
+ EOI
+ ? false
+ ? true
+ EOO
+
+ : not-false
+ :
+ $* <<EOI >>EOO
+ if false
+ cmd1
+ cmd2
+ elif! false
+ cmd3
+ cmd4
+ end
+ EOI
+ ? false
+ ? false
cmd3
cmd4
-end
-EOI
-? false
-? false
-cmd3
-cmd4
-EOO
+ EOO
+
+ : without-if
+ :
+ $* <<EOI 2>>EOE != 0
+ cmd
+ elif true
+ cmd
+ end
+ EOI
+ testscript:2:1: error: 'elif' without preceding 'if'
+ EOE
-: else-true
+ : not-without-if
+ :
+ $* <<EOI 2>>EOE != 0
+ cmd
+ elif! true
+ cmd
+ end
+ EOI
+ testscript:2:1: error: 'elif!' without preceding 'if'
+ EOE
+
+ : after-else
+ :
+ $* <<EOI 2>>EOE != 0
+ if false
+ cmd
+ else
+ cmd
+ elif true
+ cmd
+ end
+ EOI
+ testscript:5:1: error: 'elif' after 'else'
+ EOE
+}
+
+: else
:
-$* <<EOI >>EOO
-if false
- cmd1
- cmd2
-else
+{
+ : true
+ :
+ $* <<EOI >>EOO
+ if false
+ cmd1
+ cmd2
+ else
+ cmd3
+ cmd4
+ end
+ EOI
+ ? false
cmd3
cmd4
-end
-EOI
-? false
-cmd3
-cmd4
-EOO
+ EOO
-: else-false
-:
-$* <<EOI >>EOO
-if true
+ : false
+ :
+ $* <<EOI >>EOO
+ if true
+ cmd1
+ cmd2
+ else
+ cmd3
+ cmd4
+ end
+ EOI
+ ? true
cmd1
cmd2
-else
- cmd3
- cmd4
-end
-EOI
-? true
-cmd1
-cmd2
-EOO
+ EOO
-: if-chain
-:
-$* <<EOI >>EOO
-if false
- cmd
- cmd
-elif false
- cmd
- cmd
-elif false
- cmd
- cmd
-elif true
+ : chain
+ :
+ $* <<EOI >>EOO
+ if false
+ cmd
+ cmd
+ elif false
+ cmd
+ cmd
+ elif false
+ cmd
+ cmd
+ elif true
+ cmd1
+ cmd2
+ elif false
+ cmd
+ cmd
+ else
+ cmd
+ cmd
+ end
+ EOI
+ ? false
+ ? false
+ ? false
+ ? true
cmd1
cmd2
-elif false
- cmd
- cmd
-else
- cmd
+ EOO
+
+ : command-after
+ :
+ $* <<EOI 2>>EOE != 0
+ if true
+ cmd
+ else cmd
+ cmd
+ end
+ EOI
+ testscript:3:6: error: expected newline instead of 'cmd'
+ EOE
+
+ : without-if
+ :
+ $* <<EOI 2>>EOE != 0
cmd
-end
-EOI
-? false
-? false
-? false
-? true
-cmd1
-cmd2
-EOO
+ else
+ cmd
+ end
+ EOI
+ testscript:2:1: error: 'else' without preceding 'if'
+ EOE
-: nested-take
-:
-$* <<EOI >>EOO
-if true
- cmd1
+ : after-else
+ :
+ $* <<EOI 2>>EOE != 0
if false
cmd
- elif false
+ else
+ cmd
+ else
+ cmd
+ end
+ EOI
+ testscript:5:1: error: 'else' after 'else'
+ EOE
+}
+
+: end
+{
+ : without-if
+ :
+ $* <<EOI 2>>EOE != 0
+ cmd
+ end
+ EOI
+ testscript:2:1: error: 'end' without preceding 'if'
+ EOE
+
+ : before
+ {
+ : semi
+ :
+ $* -s <<EOI >>EOO
+ if true
+ cmd1
+ end;
+ cmd2
+ EOI
+ {
+ {
+ ? true
+ cmd1
+ cmd2
+ }
+ }
+ EOO
+
+ : command
+ :
+ $* <<EOI 2>>EOE != 0
if true
cmd
+ end cmd
+ EOI
+ testscript:3:5: error: expected newline instead of 'cmd'
+ EOE
+
+ : colon
+ :
+ $* -s <<EOI >>EOO
+ if true
+ cmd1
+ cmd2
+ end : test
+ EOI
+ {
+ : id:test
+ {
+ ? true
+ cmd1
+ cmd2
+ }
+ }
+ EOO
+ }
+}
+
+: nested
+:
+{
+ : take
+ :
+ $* <<EOI >>EOO
+ if true
+ cmd1
+ if false
+ cmd
+ elif false
+ if true
+ cmd
+ end
+ else
+ cmd2
end
- else
- cmd2
+ cmd3
end
+ EOI
+ ? true
+ cmd1
+ ? false
+ ? false
+ cmd2
cmd3
-end
-EOI
-? true
-cmd1
-? false
-? false
-cmd2
-cmd3
-EOO
+ EOO
-: nested-skip
-:
-$* <<EOI >>EOO
-if false
- cmd1
+ : skip
+ :
+ $* <<EOI >>EOO
if false
- cmd
- elif false
- if true
+ cmd1
+ if false
cmd
+ elif false
+ if true
+ cmd
+ end
+ else
+ cmd2
end
+ cmd3
else
- cmd2
+ cmd
end
- cmd3
-else
+ EOI
+ ? false
cmd
-end
-EOI
-? false
-cmd
-EOO
+ EOO
+}
+
+: contained
+{
+ : semi
+ :
+ $* <<EOI 2>>EOE != 0
+ if
+ cmd;
+ cmd
+ end
+ EOI
+ testscript:2:3: error: ';' inside 'if'
+ EOE
+
+ : colon-leading
+ :
+ $* <<EOI 2>>EOE != 0
+ if
+ : foo
+ cmd
+ end
+ EOI
+ testscript:2:3: error: description inside 'if'
+ EOE
+
+ : colon-trailing
+ :
+ $* <<EOI 2>>EOE != 0
+ if
+ cmd : foo
+ end
+ EOI
+ testscript:2:3: error: description inside 'if'
+ EOE
+
+ : eos
+ :
+ $* <<EOI 2>>EOE != 0
+ if
+ EOI
+ testscript:2:1: error: expected closing 'end'
+ EOE
+
+ : scope
+ :
+ $* <<EOI 2>>EOE != 0
+ if
+ cmd
+ {
+ }
+ end
+ EOI
+ testscript:3:3: error: expected closing 'end'
+ EOE
+
+ : setup
+ :
+ $* <<EOI 2>>EOE != 0
+ if
+ +cmd
+ end
+ EOI
+ testscript:2:3: error: setup command inside 'if'
+ EOE
+
+ : tdown
+ :
+ $* <<EOI 2>>EOE != 0
+ if
+ -cmd
+ end
+ EOI
+ testscript:2:3: error: teardown command inside 'if'
+ EOE
+}
: line-index
:
@@ -255,258 +536,6 @@ EOI
cmd foo
EOO
-: semi-inside
-:
-$* <<EOI 2>>EOE != 0
-if
- cmd;
- cmd
-end
-EOI
-testscript:2:3: error: ';' inside 'if'
-EOE
-
-: colon-inside-leading
-:
-$* <<EOI 2>>EOE != 0
-if
- : foo
- cmd
-end
-EOI
-testscript:2:3: error: description inside 'if'
-EOE
-
-: colon-inside-trailing
-:
-$* <<EOI 2>>EOE != 0
-if
- cmd : foo
-end
-EOI
-testscript:2:3: error: description inside 'if'
-EOE
-
-: eos-inside
-:
-$* <<EOI 2>>EOE != 0
-if
-EOI
-testscript:2:1: error: expected closing 'end'
-EOE
-
-: scope-inside
-:
-$* <<EOI 2>>EOE != 0
-if
- cmd
- {
- }
-end
-EOI
-testscript:3:3: error: expected closing 'end'
-EOE
-
-: setup-inside
-:
-$* <<EOI 2>>EOE != 0
-if
- +cmd
-end
-EOI
-testscript:2:3: error: setup command inside 'if'
-EOE
-
-: tdown-inside
-:
-$* <<EOI 2>>EOE != 0
-if
- -cmd
-end
-EOI
-testscript:2:3: error: teardown command inside 'if'
-EOE
-
-: if-without-command
-:
-$* <<EOI 2>>EOE != 0
-if
- cmd
-end
-EOI
-testscript:1:3: error: missing program
-EOE
-
-: command-after-else
-:
-$* <<EOI 2>>EOE != 0
-if true
- cmd
-else cmd
- cmd
-end
-EOI
-testscript:3:6: error: expected newline instead of 'cmd'
-EOE
-
-: command-after-end
-:
-$* <<EOI 2>>EOE != 0
-if true
- cmd
-end cmd
-EOI
-testscript:3:5: error: expected newline instead of 'cmd'
-EOE
-
-: elif-without-if
-:
-$* <<EOI 2>>EOE != 0
-cmd
-elif true
- cmd
-end
-EOI
-testscript:2:1: error: 'elif' without preceding 'if'
-EOE
-
-: elifn-without-if
-:
-$* <<EOI 2>>EOE != 0
-cmd
-elif! true
- cmd
-end
-EOI
-testscript:2:1: error: 'elif!' without preceding 'if'
-EOE
-
-: else-without-if
-:
-$* <<EOI 2>>EOE != 0
-cmd
-else
- cmd
-end
-EOI
-testscript:2:1: error: 'else' without preceding 'if'
-EOE
-
-: end-without-if
-:
-$* <<EOI 2>>EOE != 0
-cmd
-end
-EOI
-testscript:2:1: error: 'end' without preceding 'if'
-EOE
-
-: else-after-else
-:
-$* <<EOI 2>>EOE != 0
-if false
- cmd
-else
- cmd
-else
- cmd
-end
-EOI
-testscript:5:1: error: 'else' after 'else'
-EOE
-
-: elif-after-else
-:
-$* <<EOI 2>>EOE != 0
-if false
- cmd
-else
- cmd
-elif true
- cmd
-end
-EOI
-testscript:5:1: error: 'elif' after 'else'
-EOE
-
-: if-after-semi
-:
-$* -s <<EOI >>EOO
-cmd1;
-if true
- cmd2
-end
-EOI
-{
- {
- cmd1
- ? true
- cmd2
- }
-}
-EOO
-
-: setup-if
-:
-$* -s <<EOI >>EOO
-+if true
- cmd
-end
-EOI
-{
- ? true
- cmd
-}
-EOO
-
-: tdown-if
-:
-$* -s <<EOI >>EOO
--if true
- cmd
-end
-EOI
-{
- ? true
- cmd
-}
-EOO
-
-: semi-after-end
-:
-$* -s <<EOI >>EOO
-if true
- cmd1
-end;
-cmd2
-EOI
-{
- {
- ? true
- cmd1
- cmd2
- }
-}
-EOO
-
-: colon-after-end
-:
-$* -s <<EOI >>EOO
-if true
- cmd1
- cmd2
-end : test
-EOI
-{
- : id:test
- {
- ? true
- cmd1
- cmd2
- }
-}
-EOO
-
: leading-and-trailing-description
:
$* <<EOI 2>>EOE != 0