Change fast_ops to options.
This commit is contained in:
@@ -77,19 +77,22 @@ fn test_native_overload() -> Result<(), Box<EvalAltResult>> {
|
||||
|
||||
assert_eq!(
|
||||
engine.eval::<String>(r#"let x = "hello"; let y = "world"; x + y"#)?,
|
||||
if cfg!(not(feature = "fast_ops")) {
|
||||
"hello***world"
|
||||
} else {
|
||||
"helloworld"
|
||||
}
|
||||
"hello***world"
|
||||
);
|
||||
assert_eq!(
|
||||
engine.eval::<String>(r#"let x = "hello"; let y = (); x + y"#)?,
|
||||
if cfg!(not(feature = "fast_ops")) {
|
||||
"hello Foo!"
|
||||
} else {
|
||||
"hello"
|
||||
}
|
||||
"hello Foo!"
|
||||
);
|
||||
|
||||
engine.set_fast_operators(true);
|
||||
|
||||
assert_eq!(
|
||||
engine.eval::<String>(r#"let x = "hello"; let y = "world"; x + y"#)?,
|
||||
"helloworld"
|
||||
);
|
||||
assert_eq!(
|
||||
engine.eval::<String>(r#"let x = "hello"; let y = (); x + y"#)?,
|
||||
"hello"
|
||||
);
|
||||
|
||||
Ok(())
|
||||
|
@@ -49,24 +49,21 @@ fn test_optimizer_run() -> Result<(), Box<EvalAltResult>> {
|
||||
run_test(&mut engine)?;
|
||||
|
||||
// Override == operator
|
||||
#[cfg(not(feature = "fast_ops"))]
|
||||
{
|
||||
engine.register_fn("==", |_x: INT, _y: INT| false);
|
||||
engine.register_fn("==", |_x: INT, _y: INT| false);
|
||||
|
||||
engine.set_optimization_level(OptimizationLevel::Simple);
|
||||
engine.set_optimization_level(OptimizationLevel::Simple);
|
||||
|
||||
assert_eq!(
|
||||
engine.eval::<INT>("if 1 == 1 || 2 > 3 { 42 } else { 123 }")?,
|
||||
123
|
||||
);
|
||||
assert_eq!(
|
||||
engine.eval::<INT>("if 1 == 1 || 2 > 3 { 42 } else { 123 }")?,
|
||||
123
|
||||
);
|
||||
|
||||
engine.set_optimization_level(OptimizationLevel::Full);
|
||||
engine.set_optimization_level(OptimizationLevel::Full);
|
||||
|
||||
assert_eq!(
|
||||
engine.eval::<INT>("if 1 == 1 || 2 > 3 { 42 } else { 123 }")?,
|
||||
123
|
||||
);
|
||||
}
|
||||
assert_eq!(
|
||||
engine.eval::<INT>("if 1 == 1 || 2 > 3 { 42 } else { 123 }")?,
|
||||
123
|
||||
);
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
@@ -128,14 +128,7 @@ fn test_plugins_package() -> Result<(), Box<EvalAltResult>> {
|
||||
assert_eq!(engine.eval::<INT>("let a = [1, 2, 3]; test(a, 2)")?, 6);
|
||||
assert_eq!(engine.eval::<INT>("let a = [1, 2, 3]; hi(a, 2)")?, 6);
|
||||
assert_eq!(engine.eval::<INT>("let a = [1, 2, 3]; test(a, 2)")?, 6);
|
||||
assert_eq!(
|
||||
engine.eval::<INT>("2 + 2")?,
|
||||
if cfg!(not(feature = "fast_ops")) {
|
||||
5
|
||||
} else {
|
||||
4
|
||||
}
|
||||
);
|
||||
assert_eq!(engine.eval::<INT>("2 + 2")?, 5);
|
||||
assert_eq!(
|
||||
engine.eval::<String>("let a = [1, 2, 3]; greet(test(a, 2))")?,
|
||||
"6 kitties"
|
||||
|
Reference in New Issue
Block a user