Fixed bug in using error variable within catch
block.
This commit is contained in:
@@ -29,6 +29,50 @@ fn test_try_catch() -> Result<(), Box<EvalAltResult>> {
|
||||
123
|
||||
);
|
||||
|
||||
#[cfg(not(feature = "no_function"))]
|
||||
assert_eq!(
|
||||
engine.eval::<INT>(
|
||||
"
|
||||
fn foo(x) { try { throw 42; } catch (x) { return x; } }
|
||||
foo(0)
|
||||
"
|
||||
)?,
|
||||
42
|
||||
);
|
||||
|
||||
assert_eq!(
|
||||
engine.eval::<INT>(
|
||||
"
|
||||
let err = 123;
|
||||
let x = 0;
|
||||
try { throw 42; } catch(err) { return err; }
|
||||
"
|
||||
)?,
|
||||
42
|
||||
);
|
||||
|
||||
assert_eq!(
|
||||
engine.eval::<INT>(
|
||||
"
|
||||
let foo = 123;
|
||||
let x = 0;
|
||||
try { throw 42; } catch(err) { return foo; }
|
||||
"
|
||||
)?,
|
||||
123
|
||||
);
|
||||
|
||||
assert_eq!(
|
||||
engine.eval::<INT>(
|
||||
"
|
||||
let foo = 123;
|
||||
let x = 0;
|
||||
try { throw 42; } catch(err) { return err; }
|
||||
"
|
||||
)?,
|
||||
42
|
||||
);
|
||||
|
||||
#[cfg(not(feature = "unchecked"))]
|
||||
assert!(matches!(
|
||||
*engine
|
||||
|
Reference in New Issue
Block a user