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