code / tomo

Lines41.3K C23.7K Markdown9.7K YAML5.0K Tomo2.3K
7 others 763
Python231 Shell230 make212 INI47 Text21 SVG16 Lua6
(18 lines)
1 # Tests for the 'when' block
3 func main()
4 answers := [
5 (
6 when x is "A","B" then "A or B"
7 is "C" then "C"
8 else "Other"
9 ) for x in ["A", "B", "C", "D"]
11 assert answers == ["A or B", "A or B", "C", "Other"]
13 n := 23
14 assert (
15 when n is 1 Int64(1)
16 is 2 Int64(2)
17 is 21 + 2 Int64(23)
18 ) == Int64(23)