Code refactor, bug fixes, code docs.
This commit is contained in:
14
tests/engine.rs
Normal file
14
tests/engine.rs
Normal file
@@ -0,0 +1,14 @@
|
||||
use rhai::{Engine, EvalAltResult};
|
||||
|
||||
#[test]
|
||||
fn test_engine_call_fn() -> Result<(), EvalAltResult> {
|
||||
let mut engine = Engine::new();
|
||||
|
||||
let ast = Engine::compile("fn hello(x, y) { x.len() + y }")?;
|
||||
|
||||
let result: i64 = engine.call_fn("hello", ast, (&mut String::from("abc"), &mut 123_i64))?;
|
||||
|
||||
assert_eq!(result, 126);
|
||||
|
||||
Ok(())
|
||||
}
|
@@ -78,7 +78,7 @@ fn test_big_get_set() -> Result<(), EvalAltResult> {
|
||||
let mut engine = Engine::new();
|
||||
|
||||
engine.register_type::<TestChild>();
|
||||
engine.register_type::<TestParent>();
|
||||
engine.register_type_with_name::<TestParent>("TestParent");
|
||||
|
||||
engine.register_get_set("x", TestChild::get_x, TestChild::set_x);
|
||||
engine.register_get_set("child", TestParent::get_child, TestParent::set_child);
|
||||
@@ -90,5 +90,10 @@ fn test_big_get_set() -> Result<(), EvalAltResult> {
|
||||
500
|
||||
);
|
||||
|
||||
assert_eq!(
|
||||
engine.eval::<String>("let a = new_tp(); a.type_of()")?,
|
||||
"TestParent"
|
||||
);
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
Reference in New Issue
Block a user