This commit is contained in:
Stephen Chung 2020-09-15 11:26:03 +08:00
commit f69cd44f1a
2 changed files with 24 additions and 1 deletions

View File

@ -913,7 +913,7 @@ impl Module {
TypeId::of::<A>(), TypeId::of::<A>(),
TypeId::of::<B>(), TypeId::of::<B>(),
TypeId::of::<C>(), TypeId::of::<C>(),
TypeId::of::<C>(), TypeId::of::<D>(),
]; ];
self.set_fn(name, Public, &arg_types, Func::from_method(Box::new(f))) self.set_fn(name, Public, &arg_types, Func::from_method(Box::new(f)))
} }

View File

@ -78,6 +78,15 @@ fn test_module_resolver() -> Result<(), Box<EvalAltResult>> {
Ok(()) Ok(())
}); });
#[cfg(not(feature = "no_float"))]
module.set_fn_4_mut(
"sum_of_three_args".to_string(),
|target: &mut INT, a: INT, b: INT, c: f64| {
*target = a + b + c as INT;
Ok(())
}
);
resolver.insert("hello", module); resolver.insert("hello", module);
let mut engine = Engine::new(); let mut engine = Engine::new();
@ -130,6 +139,20 @@ fn test_module_resolver() -> Result<(), Box<EvalAltResult>> {
)?, )?,
42 42
); );
#[cfg(not(feature = "no_float"))]
{
assert_eq!(
engine.eval::<INT>(
r#"
import "hello" as h;
let x = 21;
h::sum_of_three_args(x, 14, 26, 2.0);
x
"#
)?,
42
);
}
#[cfg(not(feature = "unchecked"))] #[cfg(not(feature = "unchecked"))]
{ {