v2 / vlib / v / tests / consts / const_if_fixed_array_test.v
21 lines · 19 sloc · 519 bytes · 5c1662d234d8c884b8fba3828e9852f3967d7e6e
Raw
1// vtest vflags: -d some_other_define
2pub const fixed_sized_comptime_array_const = $if some_other_define ? {
3 [u8(0x01), 0x02]!
4} $else $if some_other_define_2 ? {
5 [u8(0x01), 0x02, 0x03]!
6} $else {
7 [u8(0)]!
8}
9
10pub const fixed_sized_comptime_array_const2 = $if some_other_define_2 ? {
11 [u8(0x01), 0x02, 0x03]!
12} $else $if some_other_define ? {
13 [u8(0x01), 0x02]!
14} $else {
15 [u8(0)]!
16}
17
18fn test_main() {
19 assert fixed_sized_comptime_array_const == [u8(1), 2]!
20 assert fixed_sized_comptime_array_const2 == [u8(1), 2]!
21}
22