Calculate whether contains global functions during indexing.

This commit is contained in:
Stephen Chung
2021-03-05 20:07:35 +08:00
parent 4e5039d4fe
commit 65ef32af19
4 changed files with 78 additions and 77 deletions

View File

@@ -24,10 +24,12 @@ fn test_module_sub_module() -> Result<(), Box<EvalAltResult>> {
sub_module2.set_var("answer", 41 as INT);
let hash_inc = sub_module2.set_fn_1_mut("inc", FnNamespace::Internal, |x: &mut INT| Ok(*x + 1));
assert!(!sub_module2.has_namespace(FnNamespace::Global, true));
sub_module2.build_index();
assert!(!sub_module2.contains_indexed_global_functions());
sub_module2.set_fn_1_mut("super_inc", FnNamespace::Global, |x: &mut INT| Ok(*x + 1));
assert!(sub_module2.has_namespace(FnNamespace::Global, true));
sub_module2.build_index();
assert!(sub_module2.contains_indexed_global_functions());
#[cfg(not(feature = "no_object"))]
sub_module2.set_getter_fn("doubled", |x: &mut INT| Ok(*x * 2));
@@ -35,9 +37,9 @@ fn test_module_sub_module() -> Result<(), Box<EvalAltResult>> {
sub_module.set_sub_module("universe", sub_module2);
module.set_sub_module("life", sub_module);
module.set_var("MYSTIC_NUMBER", Dynamic::from(42 as INT));
module.build_index();
assert!(module.has_namespace(FnNamespace::Global, true));
assert!(!module.has_namespace(FnNamespace::Global, false));
assert!(module.contains_indexed_global_functions());
assert!(module.contains_sub_module("life"));
let m = module.get_sub_module("life").unwrap();