v2 / vlib / v / tests / comptime / comptime_smartcast_var_test.v
22 lines · 21 sloc · 317 bytes · 6488041a749df9762348d019c4223908c476f2e2
Raw
1type TestSum = bool | f64 | int | string
2
3fn test_main() {
4 a := TestSum(true)
5 $for v in TestSum.variants {
6 if a is v {
7 $if a is bool {
8 assert a == true
9 }
10 $if a is string {
11 assert a == ''
12 }
13 $if a is f64 {
14 assert a == 0
15 }
16 $if a is int {
17 assert a == 0
18 }
19 }
20 }
21 assert true
22}
23