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-if.testscript | 554 ++++++++++++++++++++++ 1 file changed, 554 insertions(+) create mode 100644 unit-tests/test/script/parser/scope-if.testscript (limited to 'unit-tests/test/script/parser/scope-if.testscript') diff --git a/unit-tests/test/script/parser/scope-if.testscript b/unit-tests/test/script/parser/scope-if.testscript new file mode 100644 index 0000000..c76fab7 --- /dev/null +++ b/unit-tests/test/script/parser/scope-if.testscript @@ -0,0 +1,554 @@ +# file : unit-tests/test/script/parser/scope-if.testscript +# copyright : Copyright (c) 2014-2018 Code Synthesis Ltd +# license : MIT; see accompanying LICENSE file + +: if +: +{ + : true + : + $* -s <>EOO + if true foo + { + cmd + } + EOI + { + ? true foo + { + cmd + } + } + EOO + + : false + : + $* -s <>EOO + if false foo + { + cmd + } + EOI + { + ? false foo + } + EOO + + : not-true + : + $* -s <>EOO + if! true + { + cmd + } + EOI + { + ? true + } + EOO + + : not-false + : + $* -s <>EOO + if! false + { + cmd + } + EOI + { + ? false + { + cmd + } + } + EOO + + : eos-inside + : + $* <>EOE != 0 + if + { + EOI + testscript:3:1: error: expected '}' at the end of the scope + EOE + +} + +: elif +: +{ + : true + : + $* -s <>EOO + if false + { + cmd + } + elif true + { + cmd1 + } + EOI + { + ? false + ? true + { + cmd1 + } + } + EOO + + : false + : + $* -s <>EOO + if false + { + cmd + } + elif false + { + cmd + } + EOI + { + ? false + ? false + } + EOO + + : not-false + : + $* -s <>EOO + if false + { + cmd + } + elif! false + { + cmd1 + } + EOI + { + ? false + ? false + { + cmd1 + } + } + EOO + + : not-true + : + $* -s <>EOO + if false + { + cmd + } + elif! true + { + cmd + } + EOI + { + ? false + ? true + } + EOO + + : after-else + : + $* <>EOE != 0 + if false + { + cmd + } + else + { + cmd + } + elif true + { + cmd + } + EOI + testscript:9:1: error: 'elif' after 'else' + EOE +} + +: else +: +{ + : true + : + $* -s <>EOO + if false + { + cmd + } + else + { + cmd1 + } + EOI + { + ? false + { + cmd1 + } + } + EOO + + : false + : + $* -s <>EOO + if true + { + cmd1 + } + else + { + cmd + } + EOI + { + ? true + { + cmd1 + } + } + EOO + + : chain + : + $* -s <>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 + + : scope-expected + : + $* <>EOE != 0 + if + { + cmd + } + else + cmd + EOI + testscript:5:1: error: expected scope after 'else' + EOE + + : after-else + : + $* <>EOE != 0 + if false + { + cmd + } + else + { + cmd + } + else + { + cmd + } + EOI + testscript:9:1: error: 'else' after 'else' + EOE +} + +: nested +: +{ + : take + : + $* -s <>EOO + if true + { + cmd1 + if false + { + cmd + } + elif false + { + if true + { + cmd + } + } + else + { + cmd2 + } + cmd3 + } + EOI + { + ? true + { + { + cmd1 + } + ? false + ? false + { + { + cmd2 + } + } + { + cmd3 + } + } + } + EOO + + : skip + : + $* -s <>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 <>EOO + if false + { + cmd + } + elif true + { + cmd1 + cmd2 + } + else + { + cmd + } + EOI + { + ? false + ? true + { + { + cmd1 + } + { + cmd2 + } + } + } + EOO + + : test + : Chain demoted to test + : + $* -s <>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 <>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 <>EOO +if true +{ + cmd +} +if true + cmd1 + cmd2 +end +EOI +{ + ? true + { + cmd + } + { + ? true + cmd1 + cmd2 + } +} +EOO + +: shared-id-desc +: +$* -s -i <>EOO +: test summary +: +if false +{ + cmd +} +else +{ + cmd1 +} +EOI +{ + ? false + : sm:test summary + { # 3 + cmd1 + } +} +EOO -- cgit v1.1