v2 / vlib / v / tests / casts / autocast_in_if_conds_1_test.v
24 lines · 20 sloc · 296 bytes · 6488041a749df9762348d019c4223908c476f2e2
Raw
1type MySumType = S1 | S2
2
3struct S1 {
4 is_name bool
5 name string
6}
7
8struct S2 {
9 field2 bool
10}
11
12fn test_autocast_in_if_conds() {
13 s := MySumType(S1{
14 is_name: true
15 name: 'bob'
16 })
17
18 if s is S1 && s.is_name && s.name == 'bob' {
19 println('ok')
20 assert true
21 } else {
22 assert false
23 }
24}
25