Split AST::set_source into set_source/clear_source.
This commit is contained in:
@@ -247,19 +247,25 @@ fn test_module_resolver() -> Result<(), Box<EvalAltResult>> {
|
||||
)?;
|
||||
}
|
||||
|
||||
let script = r#"
|
||||
import "hello" as h;
|
||||
h::answer
|
||||
"#;
|
||||
let mut scope = Scope::new();
|
||||
#[cfg(not(feature = "no_function"))]
|
||||
{
|
||||
let script = r#"
|
||||
fn foo() {
|
||||
import "hello" as h;
|
||||
h::answer
|
||||
}
|
||||
foo() + { import "hello" as h; h::answer }
|
||||
"#;
|
||||
let mut scope = Scope::new();
|
||||
|
||||
let ast = engine.compile_into_self_contained(&mut scope, script)?;
|
||||
let ast = engine.compile_into_self_contained(&mut scope, script)?;
|
||||
|
||||
engine.set_module_resolver(DummyModuleResolver::new());
|
||||
engine.set_module_resolver(DummyModuleResolver::new());
|
||||
|
||||
assert_eq!(engine.eval_ast::<INT>(&ast)?, 42);
|
||||
assert_eq!(engine.eval_ast::<INT>(&ast)?, 84);
|
||||
|
||||
assert!(engine.eval::<INT>(script).is_err());
|
||||
assert!(engine.eval::<INT>(script).is_err());
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
Reference in New Issue
Block a user