aboutsummaryrefslogtreecommitdiff
path: root/unit-tests/test/script/parser/scope-if.test
diff options
context:
space:
mode:
Diffstat (limited to 'unit-tests/test/script/parser/scope-if.test')
-rw-r--r--unit-tests/test/script/parser/scope-if.test529
1 files changed, 529 insertions, 0 deletions
diff --git a/unit-tests/test/script/parser/scope-if.test b/unit-tests/test/script/parser/scope-if.test
new file mode 100644
index 0000000..e04c47e
--- /dev/null
+++ b/unit-tests/test/script/parser/scope-if.test
@@ -0,0 +1,529 @@
+: if-true
+:
+$* -s <<EOI >>EOO
+if true foo
+{
+ cmd
+}
+EOI
+{
+ ? true foo
+ {
+ cmd
+ }
+}
+EOO
+
+: if-false
+:
+$* -s <<EOI >>EOO
+if false foo
+{
+ cmd
+}
+EOI
+{
+ ? false foo
+}
+EOO
+
+: ifn-true
+:
+$* -s <<EOI >>EOO
+if! true
+{
+ cmd
+}
+EOI
+{
+ ? true
+}
+EOO
+
+: ifn-false
+:
+$* -s <<EOI >>EOO
+if! false
+{
+ cmd
+}
+EOI
+{
+ ? false
+ {
+ cmd
+ }
+}
+EOO
+
+: elif-true
+:
+$* -s <<EOI >>EOO
+if false
+{
+ cmd
+}
+elif true
+{
+ cmd1
+}
+EOI
+{
+ ? false
+ ? true
+ {
+ cmd1
+ }
+}
+EOO
+
+: elif-false
+:
+$* -s <<EOI >>EOO
+if false
+{
+ cmd
+}
+elif false
+{
+ cmd
+}
+EOI
+{
+ ? false
+ ? false
+}
+EOO
+
+: elifn-false
+:
+$* -s <<EOI >>EOO
+if false
+{
+ cmd
+}
+elif! false
+{
+ cmd1
+}
+EOI
+{
+ ? false
+ ? false
+ {
+ cmd1
+ }
+}
+EOO
+
+: elifn-true
+:
+$* -s <<EOI >>EOO
+if false
+{
+ cmd
+}
+elif! true
+{
+ cmd
+}
+EOI
+{
+ ? false
+ ? true
+}
+EOO
+
+: else-true
+:
+$* -s <<EOI >>EOO
+if false
+{
+ cmd
+}
+else
+{
+ cmd1
+}
+EOI
+{
+ ? false
+ {
+ cmd1
+ }
+}
+EOO
+
+: else-false
+:
+$* -s <<EOI >>EOO
+if true
+{
+ cmd1
+}
+else
+{
+ cmd
+}
+EOI
+{
+ ? true
+ {
+ cmd1
+ }
+}
+EOO
+
+: if-chain
+:
+$* -s <<EOI >>EOO
+if false
+{
+ cmd
+}
+elif false
+{
+ cmd
+ cmd
+}
+elif false
+{
+ cmd
+}
+elif true
+{
+ cmd1
+ cmd2
+}
+elif false
+{
+ cmd
+}
+else
+{
+ cmd
+ cmd
+}
+EOI
+{
+ ? false
+ ? false
+ ? false
+ ? true
+ {
+ {
+ cmd1
+ }
+ {
+ cmd2
+ }
+ }
+}
+EOO
+
+: nested-take
+:
+$* -s <<EOI >>EOO
+if true
+{
+ cmd1
+ if false
+ {
+ cmd
+ }
+ elif false
+ {
+ if true
+ {
+ cmd
+ }
+ }
+ else
+ {
+ cmd2
+ }
+ cmd3
+}
+EOI
+{
+ ? true
+ {
+ {
+ cmd1
+ }
+ ? false
+ ? false
+ {
+ {
+ cmd2
+ }
+ }
+ {
+ cmd3
+ }
+ }
+}
+EOO
+
+: nested-skip
+:
+$* -s <<EOI >>EOO
+if false
+{
+ cmd1
+ if false
+ {
+ cmd
+ }
+ elif false
+ {
+ if true
+ {
+ cmd
+ }
+ }
+ else
+ {
+ cmd2
+ }
+ cmd3
+}
+else
+{
+ cmd
+}
+EOI
+{
+ ? false
+ {
+ {
+ cmd
+ }
+ }
+}
+EOO
+
+: demote-group
+: Chain remains a group
+:
+$* -s <<EOI >>EOO
+if false
+{
+ cmd
+}
+elif true
+{
+ cmd1
+ cmd2
+}
+else
+{
+ cmd
+}
+EOI
+{
+ ? false
+ ? true
+ {
+ {
+ cmd1
+ }
+ {
+ cmd2
+ }
+ }
+}
+EOO
+
+: demote-test
+: Chain demoted to test
+:
+$* -s <<EOI >>EOO
+if false
+{
+ cmd
+}
+elif true
+{
+ cmd1
+}
+else
+{
+ cmd
+}
+EOI
+{
+ ? false
+ ? true
+ {
+ cmd1
+ }
+}
+EOO
+
+: line-index
+: Make sure command line index spans setup/if/teardown
+:
+$* -s -l <<EOI >>EOO
++setup # 1
+
+if false one # 2
+{
+ cmd
+}
+elif false two # 3
+{
+ cmd
+}
+elif true # 4
+{
+ cmd1
+}
+elif false # 5
+{
+ cmd
+}
+else
+{
+ cmd
+}
+
+if false one # 6
+{
+ cmd
+}
+elif false two # 7
+{
+ cmd
+}
+else
+{
+ cmd2
+}
+
+-tdown # 8
+EOI
+{
+ setup # 1
+ ? false one # 2
+ ? false two # 3
+ ? true # 4
+ {
+ cmd1 # 0
+ }
+ ? false one # 6
+ ? false two # 7
+ {
+ cmd2 # 0
+ }
+ tdown # 8
+}
+EOO
+
+: scope-comman-if
+:
+$* -s <<EOI >>EOO
+if true
+{
+ cmd
+}
+if true
+ cmd1
+ cmd2
+end
+EOI
+{
+ ? true
+ {
+ cmd
+ }
+ {
+ ? true
+ cmd1
+ cmd2
+ }
+}
+EOO
+
+: shared-id-desc
+:
+$* -s -i <<EOI >>EOO
+: test summary
+:
+if false
+{
+ cmd
+}
+else
+{
+ cmd1
+}
+EOI
+{
+ ? false
+ : sm:test summary
+ { # 3
+ cmd1
+ }
+}
+EOO
+
+: eos-inside
+:
+$* <<EOI 2>>EOE != 0
+if
+{
+EOI
+testscript:3:1: error: expected '}' at the end of the scope
+EOE
+
+: scope-expected
+:
+$* <<EOI 2>>EOE != 0
+if
+{
+ cmd
+}
+else
+cmd
+EOI
+testscript:5:1: error: expected scope after 'else'
+EOE
+
+: else-after-else
+:
+$* <<EOI 2>>EOE != 0
+if false
+{
+ cmd
+}
+else
+{
+ cmd
+}
+else
+{
+ cmd
+}
+EOI
+testscript:9:1: error: 'else' after 'else'
+EOE
+
+: elif-after-else
+:
+$* <<EOI 2>>EOE != 0
+if false
+{
+ cmd
+}
+else
+{
+ cmd
+}
+elif true
+{
+ cmd
+}
+EOI
+testscript:9:1: error: 'elif' after 'else'
+EOE