use rhai::{Engine, EvalAltResult, INT, Scope};
use rhai::packages::{Package, StandardPackage};
#[test]
fn test_packages() -> Result<(), Box<EvalAltResult>> {
let e = Engine::new();
let ast = e.compile("x")?;
let std_pkg = StandardPackage::new();
let make_call = |x: INT| -> Result<INT, Box<EvalAltResult>> {
let mut engine = Engine::new_raw();
engine.load_package(std_pkg.get());
let mut scope = Scope::new();
scope.push("x", x);
engine.eval_ast_with_scope::<INT>(&mut scope, &ast)
};
for x in 0..10_000 {
assert_eq!(make_call(x)?, x);
}
Ok(())
}