diff --git a/tests/plugins.rs b/tests/plugins.rs index 3379b411..5331287b 100644 --- a/tests/plugins.rs +++ b/tests/plugins.rs @@ -7,6 +7,10 @@ use rhai::{Engine, EvalAltResult, INT}; mod special_array_package { use rhai::{Array, INT}; + #[rhai_fn(get = "foo", return_raw)] + pub fn foo(array: &mut Array) -> Result> { + Ok(array[0].clone()) + } #[rhai_fn(name = "test")] pub fn len(array: &mut Array, mul: INT) -> INT { (array.len() as INT) * mul @@ -53,6 +57,7 @@ fn test_plugins_package() -> Result<(), Box> { reg_functions!(engine += greet::single(INT, bool, char)); + assert_eq!(engine.eval::("let a = [1, 2, 3]; a.foo")?, 1); assert_eq!(engine.eval::("let a = [1, 2, 3]; test(a, 2)")?, 6); assert_eq!(engine.eval::("2 + 2")?, 5); assert_eq!(