diff options
Diffstat (limited to 'tests/casestmt/tcasestm.nim')
-rw-r--r-- | tests/casestmt/tcasestm.nim | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/tests/casestmt/tcasestm.nim b/tests/casestmt/tcasestm.nim new file mode 100644 index 000000000..003ec6e50 --- /dev/null +++ b/tests/casestmt/tcasestm.nim @@ -0,0 +1,40 @@ +discard """ + file: "tcasestm.nim" + output: "ayyydd" +""" +# Test the case statement + +type + tenum = enum eA, eB, eC + +var + x: string = "yyy" + y: Tenum = eA + i: int + +case y +of eA: write(stdout, "a") +of eB, eC: write(stdout, "b or c") + +case x +of "Andreas", "Rumpf": write(stdout, "Hallo Meister!") +of "aa", "bb": write(stdout, "Du bist nicht mein Meister") +of "cc", "hash", "when": nil +of "will", "it", "finally", "be", "generated": nil + +var z = case i + of 1..5, 8, 9: "aa" + of 6, 7: "bb" + elif x == "Ha": + "cc" + elif x == "yyy": + write(stdout, x) + "dd" + else: + "zz" + +echo z +#OUT ayyy + + + |