From c8b59bd9cac673f11ae77a8a62f82fbfb5207982 Mon Sep 17 00:00:00 2001 From: Stephen Chung Date: Mon, 8 Nov 2021 23:24:03 +0800 Subject: [PATCH] Fix test. --- tests/optimizer.rs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/tests/optimizer.rs b/tests/optimizer.rs index ae071910..1b617e7d 100644 --- a/tests/optimizer.rs +++ b/tests/optimizer.rs @@ -108,21 +108,27 @@ fn test_optimizer_parse() -> Result<(), Box> { Ok(()) } +#[cfg(not(feature = "no_function"))] #[test] fn test_optimizer_scope() -> Result<(), Box> { + const SCRIPT: &str = " + fn foo() { FOO } + foo() + "; + let engine = Engine::new(); let mut scope = Scope::new(); scope.push_constant("FOO", 42 as INT); - let ast = engine.compile_with_scope(&scope, "fn foo() { FOO } foo()")?; + let ast = engine.compile_with_scope(&scope, SCRIPT)?; scope.push("FOO", 123 as INT); assert_eq!(engine.eval_ast::(&ast)?, 42); assert_eq!(engine.eval_ast_with_scope::(&mut scope, &ast)?, 42); - let ast = engine.compile_with_scope(&scope, "fn foo() { FOO } foo()")?; + let ast = engine.compile_with_scope(&scope, SCRIPT)?; assert!(engine.eval_ast_with_scope::(&mut scope, &ast).is_err());