v2 / vlib / v / checker / tests / always_true_false_branch.vv
204 lines · 194 sloc · 2.56 KB · 9760a9c6b258017ed728d323cbcd3f7016c40c3b
Raw
1module main
2
3fn main() {
4 x := 1
5 if_always_true := if x == x {
6 1
7 } else if true {
8 1
9 } else if !false {
10 1
11 } else if true == true {
12 1
13 } else if true != false {
14 1
15 } else if false == false {
16 1
17 } else if false != true {
18 1
19 } else if 'a' == 'a' {
20 1
21 } else if 'a' != 'b' {
22 1
23 } else if 1 == 1 {
24 1
25 } else if 1 != 2 {
26 1
27 } else if 1 >= 1 {
28 1
29 } else if 1 <= 1 {
30 1
31 } else if 1 < 2 {
32 1
33 } else if 2 > 1 {
34 1
35 } else if 1.5 == 1.5 {
36 1
37 } else if 1.5 != 2.5 {
38 1
39 } else if 1.5 >= 1.5 {
40 1
41 } else if 1.5 <= 1.5 {
42 1
43 } else if 1.5 < 2.5 {
44 1
45 } else if 2.5 > 1.5 {
46 1
47 } else if `1` == `1` {
48 1
49 } else if `1` != `2` {
50 1
51 } else if `1` >= `1` {
52 1
53 } else if `1` <= `1` {
54 1
55 } else if `1` < `2` {
56 1
57 } else if `2` > `1` {
58 1
59 } else if 1 == 1 && 2 <= 2 && 3 >= 3 && 4 != 5 {
60 1
61 } else if 1 == 1 || 4 > 5 || 6 < 3 || 5 != 5 {
62 1
63 } else {
64 0
65 }
66
67 dump(if_always_true)
68
69 if_always_false := if x != x {
70 1
71 } else if false {
72 1
73 } else if !true {
74 1
75 } else if true != true {
76 1
77 } else if true == false {
78 1
79 } else if false != false {
80 1
81 } else if false == true {
82 1
83 } else if 'a' != 'a' {
84 1
85 } else if 'a' == 'b' {
86 1
87 } else if 1 != 1 {
88 1
89 } else if 1 == 2 {
90 1
91 } else if 1 > 1 {
92 1
93 } else if 1 < 1 {
94 1
95 } else if 1 >= 2 {
96 1
97 } else if 2 <= 1 {
98 1
99 } else if 1.5 != 1.5 {
100 1
101 } else if 1.5 == 2.5 {
102 1
103 } else if 1.5 > 1.5 {
104 1
105 } else if 1.5 < 1.5 {
106 1
107 } else if 1.5 >= 2.5 {
108 1
109 } else if 2.5 <= 1.5 {
110 1
111 } else if `1` != `1` {
112 1
113 } else if `1` == `2` {
114 1
115 } else if `1` < `1` {
116 1
117 } else if `1` > `1` {
118 1
119 } else if `1` >= `2` {
120 1
121 } else if `2` <= `1` {
122 1
123 } else if 1 == 2 && 3 >= 3 && 4 <= 5 && 5 != 5 {
124 1
125 } else if 1 == 2 || 2 > 3 || 5 < 4 {
126 0
127 } else {
128 0
129 }
130
131 dump(if_always_false)
132
133 match_always_true_var := match x {
134 x {
135 'haha'
136 }
137 else {
138 'cc'
139 }
140 }
141 dump(match_always_true_var)
142
143 match_always_true_false_bool := match true {
144 true {
145 'haha'
146 }
147 false {
148 'cc'
149 }
150 }
151 dump(match_always_true_false_bool)
152
153 match_always_true_false_int := match 1 {
154 1 {
155 'haha'
156 }
157 2 {
158 'cc'
159 }
160 else {
161 'bb'
162 }
163 }
164 dump(match_always_true_false_int)
165
166 match_always_true_false_f64 := match 1.5 {
167 1.5 {
168 'haha'
169 }
170 2.5 {
171 'cc'
172 }
173 else {
174 'bb'
175 }
176 }
177 dump(match_always_true_false_f64)
178
179 match_always_true_false_string := match 'a' {
180 'a' {
181 'haha'
182 }
183 'b' {
184 'cc'
185 }
186 else {
187 'bb'
188 }
189 }
190 dump(match_always_true_false_string)
191
192 match_always_true_false_rune := match `a` {
193 `a` {
194 'haha'
195 }
196 `b` {
197 'cc'
198 }
199 else {
200 'bb'
201 }
202 }
203 dump(match_always_true_false_rune)
204}
205