summary refs log tree commit diff stats
path: root/tests/run/tcasestm.nim
blob: 003ec6e50b6be8eb538994153eb7844a666a7287 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
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