Fix bug where plugin module parameters are consumed.

This commit is contained in:
Stephen Chung
2021-01-23 09:37:27 +08:00
parent 8aae3ac46c
commit 3b42cc5bb2
3 changed files with 43 additions and 22 deletions

View File

@@ -101,3 +101,32 @@ fn test_plugins_package() -> Result<(), Box<EvalAltResult>> {
Ok(())
}
#[test]
fn test_plugins_parameters() -> Result<(), Box<EvalAltResult>> {
#[export_module]
mod rhai_std {
use rhai::*;
pub fn noop(_: &str) {}
}
let mut engine = Engine::new();
let std = exported_module!(rhai_std);
engine.register_static_module("std", std.into());
assert_eq!(
engine.eval::<String>(
r#"
let s = "hello";
std::noop(s);
s
"#
)?,
"hello"
);
Ok(())
}