Unit test for registered functions in anon function context
This commit is contained in:
parent
45d021c7ef
commit
9c6584240f
@ -38,7 +38,7 @@ fn test_fn_ptr_curry_call() -> Result<(), Box<EvalAltResult>> {
|
|||||||
#[cfg(not(feature = "no_closure"))]
|
#[cfg(not(feature = "no_closure"))]
|
||||||
#[cfg(not(feature = "no_object"))]
|
#[cfg(not(feature = "no_object"))]
|
||||||
fn test_closures() -> Result<(), Box<EvalAltResult>> {
|
fn test_closures() -> Result<(), Box<EvalAltResult>> {
|
||||||
let engine = Engine::new();
|
let mut engine = Engine::new();
|
||||||
|
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
engine.eval::<INT>(
|
engine.eval::<INT>(
|
||||||
@ -77,6 +77,23 @@ fn test_closures() -> Result<(), Box<EvalAltResult>> {
|
|||||||
"#
|
"#
|
||||||
)?);
|
)?);
|
||||||
|
|
||||||
|
let mut module = Module::new();
|
||||||
|
|
||||||
|
module.set_fn_1("plus_one", |x: INT| Ok(x + 1));
|
||||||
|
|
||||||
|
engine.load_package(module);
|
||||||
|
|
||||||
|
assert_eq!(
|
||||||
|
engine.eval::<INT>(
|
||||||
|
r#"
|
||||||
|
let a = 41;
|
||||||
|
let f = || plus_one(a);
|
||||||
|
f.call()
|
||||||
|
"#
|
||||||
|
)?,
|
||||||
|
42
|
||||||
|
);
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user