v2 / vlib / v / gen / wasm / tests / match_ranges.vv
126 lines · 116 sloc · 1.17 KB · 2c5a2c86c178f35d51d61f0aa008f2b98340a180
Raw
1fn main() {
2 g := 32
3 result1 := match g {
4 1...64 {
5 'Right'
6 }
7 else {
8 'Wrong'
9 }
10 }
11 println(result1)
12
13 h := 100
14 result2 := match h {
15 1...64 {
16 'Wrong'
17 }
18 else {
19 'Right'
20 }
21 }
22 println(result2)
23
24 i := 1
25 result3 := match i {
26 1...10 {
27 'Right'
28 }
29 else {
30 'Wrong'
31 }
32 }
33 println(result3)
34
35 j := 10
36 result4 := match j {
37 1...10 {
38 'Right'
39 }
40 else {
41 'Wrong'
42 }
43 }
44 println(result4)
45
46 k := 50
47 result5 := match k {
48 1...32 {
49 'Wrong'
50 }
51 33...64 {
52 'Right'
53 }
54 else {
55 'Wrong'
56 }
57 }
58 println(result5)
59
60 n := 15
61 result6 := match n {
62 1...10 {
63 10
64 }
65 11...20 {
66 20
67 }
68 else {
69 0
70 }
71 }
72 println(result6)
73
74 o := i64(500)
75 result7 := match o {
76 i64(1)...i64(1000) {
77 'Right'
78 }
79 else {
80 'Wrong'
81 }
82 }
83 println(result7)
84
85 p := u32(50)
86 result8 := match p {
87 u32(0)...u32(100) {
88 'Right'
89 }
90 else {
91 'Wrong'
92 }
93 }
94 println(result8)
95
96 r := -5
97 result9 := match r {
98 -10...-1 {
99 'Right'
100 }
101 else {
102 'Wrong'
103 }
104 }
105 println(result9)
106
107 s := 0
108 result10 := match s {
109 -10...25 {
110 'Right'
111 }
112 else {
113 'Wrong'
114 }
115 }
116 println(result10)
117
118 println(match 1234 {
119 -1200...1 {
120 'Wrong'
121 }
122 else {
123 'Right'
124 }
125 })
126}
127