From 2c631daa07b01fb057c0b2350aefef14b95ec2c3 Mon Sep 17 00:00:00 2001 From: Stephen Chung Date: Sat, 28 Jan 2023 12:40:42 +0800 Subject: [PATCH] Add test for auto global constants for global namespace. --- tests/functions.rs | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/tests/functions.rs b/tests/functions.rs index 8e4a7f36..af9b9ba0 100644 --- a/tests/functions.rs +++ b/tests/functions.rs @@ -143,6 +143,21 @@ fn test_functions_global_module() -> Result<(), Box> { 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::( + " + fn foo() { global::ANSWER } + foo() + " + )?, + 123 + ); + Ok(()) }