Add function pointer short-hand.

This commit is contained in:
Stephen Chung
2022-08-05 23:30:44 +08:00
parent ca65e17610
commit d8532b48b6
8 changed files with 68 additions and 13 deletions

View File

@@ -77,6 +77,20 @@ fn test_fn_ptr() -> Result<(), Box<EvalAltResult>> {
if fn_name == "foo" && matches!(*err, EvalAltResult::ErrorUnboundThis(..))
));
#[cfg(not(feature = "no_function"))]
assert_eq!(
engine.eval::<INT>(
r#"
fn foo(x) { x + 1 }
let f = foo;
let g = 42;
g = foo;
call(f, 39) + call(g, 1)
"#
)?,
42
);
Ok(())
}