aboutsummaryrefslogtreecommitdiff
path: root/spec/inputs
diff options
context:
space:
mode:
authorLi Jin <dragon-fly@qq.com>2025-05-07 18:16:22 +0800
committerLi Jin <dragon-fly@qq.com>2025-05-07 18:16:22 +0800
commitd905d9744344da7376ae56e7dc270a81da33d15f (patch)
tree3d3674024308ee663763bed14ffd8dee8da666ed /spec/inputs
parentc925dbea9c9108a18b9abf4a57d9d59b0ed04652 (diff)
downloadyuescript-d905d9744344da7376ae56e7dc270a81da33d15f.tar.gz
yuescript-d905d9744344da7376ae56e7dc270a81da33d15f.tar.bz2
yuescript-d905d9744344da7376ae56e7dc270a81da33d15f.zip
Updated.
Diffstat (limited to 'spec/inputs')
-rw-r--r--spec/inputs/switch.yue56
1 files changed, 55 insertions, 1 deletions
diff --git a/spec/inputs/switch.yue b/spec/inputs/switch.yue
index 49d47f3..7ff3118 100644
--- a/spec/inputs/switch.yue
+++ b/spec/inputs/switch.yue
@@ -165,5 +165,59 @@ do
165 print item 165 print item
166 when [a = 1, b = "abc"] 166 when [a = 1, b = "abc"]
167 print a, b 167 print a, b
168nil
169 168
169do
170 switch tb
171 when [1, 2, 3]
172 print "1, 2, 3"
173 when [1, b, 3]
174 print "1, #{b}, 3"
175 when [1, 2, b = 3]
176 print "1, 2, #{b}"
177
178do
179 switch tb
180 when success: true, :result
181 print "success", result
182 when success: false
183 print "failed", result
184 else
185 print "invalid"
186
187do
188 switch tb
189 when {type: "success", :content}
190 print "success", content
191 when {type: "error", :content}
192 print "failed", content
193 else
194 print "invalid"
195
196do
197 switch tb
198 when [
199 {a: 1, b: 2}
200 {a: 3, b: 4}
201 {a: 5, b: 6}
202 fourth
203 ]
204 print "matched", fourth
205
206 switch tb
207 when [
208 {c: 1, d: 2}
209 {c: 3, d: 4}
210 {c: 5, d: 6}
211 ]
212 print "OK"
213 when [
214 _
215 _
216 {a: 1, b: 2}
217 {a: 3, b: 4}
218 {a: 5, b: 6}
219 sixth
220 ]
221 print "matched", sixth
222
223nil \ No newline at end of file