Merge branch 'main' of github.com:Mathieu-Lala/rhai into fix/lint
This commit is contained in:
@@ -133,6 +133,20 @@ fn test_arrays() -> Result<(), Box<EvalAltResult>> {
|
||||
);
|
||||
}
|
||||
|
||||
#[cfg(not(feature = "no_object"))]
|
||||
assert_eq!(
|
||||
engine.eval::<INT>(
|
||||
"
|
||||
let x = #{ foo: 42 };
|
||||
let n = 0;
|
||||
let a = [[x]];
|
||||
let i = [n];
|
||||
a[n][i[n]].foo
|
||||
"
|
||||
)?,
|
||||
42
|
||||
);
|
||||
|
||||
assert_eq!(
|
||||
engine
|
||||
.eval::<Dynamic>(
|
||||
|
@@ -144,6 +144,21 @@ fn test_functions_global_module() -> Result<(), Box<EvalAltResult>> {
|
||||
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(())
|
||||
}
|
||||
|
||||
|
@@ -17,6 +17,13 @@ fn test_module() {
|
||||
assert_eq!(module.get_var_value::<INT>("answer").unwrap(), 42);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_module_syntax() {
|
||||
let engine = Engine::new();
|
||||
assert!(engine.compile("abc.def::xyz").is_err());
|
||||
assert!(engine.compile("abc.def::xyz()").is_err());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_module_sub_module() -> Result<(), Box<EvalAltResult>> {
|
||||
let mut module = Module::new();
|
||||
|
Reference in New Issue
Block a user