v2 / vlib / v / tests / array_fixed_ternary_test.v
29 lines · 24 sloc · 560 bytes · 8e35f4d9848f7ad35d857a187dddbfd2eca5e19d
Raw
1fn test_main() {
2 _ := if true { [0]! } else { [1]! }
3 _ := if true { [0] } else { [1] }
4
5 a := if true { [0]! } else { [1]! }
6 b := if true { [0] } else { [1] }
7 assert a.str() == '[0]'
8 assert b.str() == '[0]'
9}
10
11fn test_match() {
12 grid_size := 1
13
14 _ := match grid_size {
15 3 { ['Small', '3x3']! }
16 4 { ['Classic', '4x4']! }
17 5 { ['Big', '5x5']! }
18 else { ['Large', '6x6']! }
19 }
20
21 w := match grid_size {
22 3 { ['Small', '3x3']! }
23 4 { ['Classic', '4x4']! }
24 5 { ['Big', '5x5']! }
25 else { ['Large', '6x6']! }
26 }
27
28 assert w.str() == "['Large', '6x6']"
29}
30