v2 / vlib / v / tests / comptime / comptime_match_at_expr_test.v
44 lines · 39 sloc · 511 bytes · f6b60e4d9f4213f5fa08651da7af7b4ef2806ce1
Raw
1module main
2
3$match @MOD {
4 'main' {
5 const c1 = 'main'
6 }
7 $else {
8 const c1 = 'other'
9 }
10}
11
12$match @OS {
13 'linux' {
14 const os = 'linux'
15 }
16 'windows' {
17 const os = 'windows'
18 }
19 $else {
20 const os = 'other'
21 }
22}
23
24fn test_comptime_match_at_expr() {
25 assert c1 == 'main'
26
27 dump(@FN)
28 $match @FN {
29 'test_comptime_match_at_expr' {
30 assert true
31 }
32 $else {
33 assert false
34 }
35 }
36
37 $if linux {
38 assert os == 'linux'
39 } $else $if windows {
40 assert os == 'windows'
41 } $else {
42 assert os == 'other'
43 }
44}
45