Make fast operators the default.
This commit is contained in:
@@ -75,17 +75,6 @@ fn test_native_overload() -> Result<(), Box<EvalAltResult>> {
|
||||
format!("{s1} Foo!").into()
|
||||
});
|
||||
|
||||
assert_eq!(
|
||||
engine.eval::<String>(r#"let x = "hello"; let y = "world"; x + y"#)?,
|
||||
"hello***world"
|
||||
);
|
||||
assert_eq!(
|
||||
engine.eval::<String>(r#"let x = "hello"; let y = (); x + y"#)?,
|
||||
"hello Foo!"
|
||||
);
|
||||
|
||||
engine.set_fast_operators(true);
|
||||
|
||||
assert_eq!(
|
||||
engine.eval::<String>(r#"let x = "hello"; let y = "world"; x + y"#)?,
|
||||
"helloworld"
|
||||
@@ -95,5 +84,16 @@ fn test_native_overload() -> Result<(), Box<EvalAltResult>> {
|
||||
"hello"
|
||||
);
|
||||
|
||||
engine.set_fast_operators(false);
|
||||
|
||||
assert_eq!(
|
||||
engine.eval::<String>(r#"let x = "hello"; let y = "world"; x + y"#)?,
|
||||
"hello***world"
|
||||
);
|
||||
assert_eq!(
|
||||
engine.eval::<String>(r#"let x = "hello"; let y = (); x + y"#)?,
|
||||
"hello Foo!"
|
||||
);
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
@@ -53,6 +53,13 @@ fn test_optimizer_run() -> Result<(), Box<EvalAltResult>> {
|
||||
|
||||
engine.set_optimization_level(OptimizationLevel::Simple);
|
||||
|
||||
assert_eq!(
|
||||
engine.eval::<INT>("if 1 == 1 || 2 > 3 { 42 } else { 123 }")?,
|
||||
42
|
||||
);
|
||||
|
||||
engine.set_fast_operators(false);
|
||||
|
||||
assert_eq!(
|
||||
engine.eval::<INT>("if 1 == 1 || 2 > 3 { 42 } else { 123 }")?,
|
||||
123
|
||||
|
@@ -128,11 +128,14 @@ 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")?, 5);
|
||||
assert_eq!(
|
||||
engine.eval::<String>("let a = [1, 2, 3]; greet(test(a, 2))")?,
|
||||
"6 kitties"
|
||||
);
|
||||
assert_eq!(engine.eval::<INT>("2 + 2")?, 4);
|
||||
|
||||
engine.set_fast_operators(false);
|
||||
assert_eq!(engine.eval::<INT>("2 + 2")?, 5);
|
||||
|
||||
engine.register_static_module("test", exported_module!(test::special_array_package).into());
|
||||
|
||||
|
Reference in New Issue
Block a user