Refine modules.

This commit is contained in:
Stephen Chung
2020-05-04 23:07:42 +08:00
parent 2bdd174f16
commit 64036f69ca
7 changed files with 186 additions and 57 deletions

15
tests/modules.rs Normal file
View File

@@ -0,0 +1,15 @@
use rhai::{EvalAltResult, Scope, SubScope, INT};
#[test]
#[cfg(not(feature = "no_import"))]
fn test_sub_scope() {
let mut my_scope = Scope::new();
let mut sub_scope = SubScope::new();
sub_scope.insert("x".to_string(), (42 as INT).into());
my_scope.push_sub_scope("my_plugin", sub_scope);
let s = my_scope.find_sub_scope("my_plugin").unwrap();
assert_eq!(*s.get("x").unwrap().downcast_ref::<INT>().unwrap(), 42);
}