Add case alternatives for switch.
This commit is contained in:
@@ -45,6 +45,13 @@ fn test_switch() -> Result<(), Box<EvalAltResult>> {
|
||||
engine.eval_with_scope::<()>(&mut scope, "switch x { 1 => 123, 2 => 'a' }")?,
|
||||
()
|
||||
);
|
||||
assert_eq!(
|
||||
engine.eval_with_scope::<INT>(
|
||||
&mut scope,
|
||||
"switch x { 1 | 2 | 3 | 5..50 | 'x' | true => 123, 'z' => 'a' }"
|
||||
)?,
|
||||
123
|
||||
);
|
||||
assert_eq!(
|
||||
engine.eval::<INT>("let x = timestamp(); switch x { 1 => 123, _ => 42 }")?,
|
||||
42
|
||||
|
Reference in New Issue
Block a user