v2 / vlib / v / tests / match_branch_par_expr_test.v
32 lines · 29 sloc · 433 bytes · 31636fbc9bbdbc93d86a8fdbeff572c1daf901ad
Raw
1module main
2
3enum TokenType {
4 null
5 word
6 get_word
7 set_word
8 lit_word
9 int_value
10 dec_value
11 bin_value
12 str_value
13 block_start
14 block_end
15 expr_start
16 expr_end
17 comment
18}
19
20fn test_match_branch_par_expr() {
21 t := TokenType.word
22 s := match t {
23 (TokenType.null) { '' }
24 (TokenType.word) { 'a' }
25 (TokenType.get_word) { 'b' }
26 (TokenType.set_word) { 'c' }
27 (TokenType.lit_word) { 'd' }
28 else { 'other' }
29 }
30
31 assert s == 'a'
32}
33