Add new macro_register test which runs in no_std
This commit is contained in:
parent
1a2ef7b531
commit
a25f6b35a1
17
tests/macro_register.rs
Normal file
17
tests/macro_register.rs
Normal 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(())
|
||||
}
|
Loading…
Reference in New Issue
Block a user