Add new macro_register test which runs in no_std

This commit is contained in:
J Henry Waugh 2020-08-12 23:46:12 -05:00
parent 1a2ef7b531
commit a25f6b35a1

17
tests/macro_register.rs Normal file
View File

@ -0,0 +1,17 @@
use rhai::plugin::*;
use rhai::{Engine, EvalAltResult, INT};
#[export_fn]
pub fn add_together(x: INT, y: INT) -> INT {
x + y
}
#[test]
fn test_exported_fn_register() -> Result<(), Box<EvalAltResult>> {
let mut engine = Engine::new();
register_exported_fn!(engine, "add_two", add_together);
assert_eq!(engine.eval::<INT>("let a = 1; add_two(a, 41)")?, 42);
Ok(())
}