diff options
Diffstat (limited to 'spec/inputs')
| -rw-r--r-- | spec/inputs/switch.yue | 56 |
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 |
| 168 | nil | ||
| 169 | 168 | ||
| 169 | do | ||
| 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 | |||
| 178 | do | ||
| 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 | |||
| 187 | do | ||
| 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 | |||
| 196 | do | ||
| 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 | |||
| 223 | nil \ No newline at end of file | ||
