From 770d4a997eab25a04cdfd83b325491a2e63bea08 Mon Sep 17 00:00:00 2001 From: Zahary Karadjov Date: Mon, 1 Oct 2012 23:48:37 +0300 Subject: implemented case expressions --- tests/run/tcasestm.nim | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) (limited to 'tests/run') diff --git a/tests/run/tcasestm.nim b/tests/run/tcasestm.nim index cb63e0c51..003ec6e50 100755 --- a/tests/run/tcasestm.nim +++ b/tests/run/tcasestm.nim @@ -1,6 +1,6 @@ discard """ file: "tcasestm.nim" - output: "ayyy" + output: "ayyydd" """ # Test the case statement @@ -22,16 +22,18 @@ of "aa", "bb": write(stdout, "Du bist nicht mein Meister") of "cc", "hash", "when": nil of "will", "it", "finally", "be", "generated": nil -case i -of 1..5, 8, 9: nil -of 6, 7: nil -elif x == "Ha": - nil -elif x == "yyy": - write(stdout, x) -else: - 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 -- cgit 1.4.1-2-gfad0