Add test for auto global constants for global namespace.

This commit is contained in:
Stephen Chung 2023-01-28 12:40:42 +08:00
parent f4949a2beb
commit 2c631daa07

View File

@ -143,6 +143,21 @@ fn test_functions_global_module() -> Result<(), Box<EvalAltResult>> {
123 123
); );
// Other globals
let mut module = Module::new();
module.set_var("ANSWER", 123 as INT);
engine.register_global_module(module.into());
assert_eq!(
engine.eval::<INT>(
"
fn foo() { global::ANSWER }
foo()
"
)?,
123
);
Ok(()) Ok(())
} }