Fix tests.

This commit is contained in:
Stephen Chung 2022-09-03 11:29:29 +08:00
parent fcdd2eb143
commit d7dfa1a218
2 changed files with 19 additions and 3 deletions

View File

@ -77,11 +77,19 @@ fn test_native_overload() -> Result<(), Box<EvalAltResult>> {
assert_eq!( assert_eq!(
engine.eval::<String>(r#"let x = "hello"; let y = "world"; x + y"#)?, engine.eval::<String>(r#"let x = "hello"; let y = "world"; x + y"#)?,
"hello***world" if cfg!(not(feature = "fast_ops")) {
"hello***world"
} else {
"helloworld"
}
); );
assert_eq!( assert_eq!(
engine.eval::<String>(r#"let x = "hello"; let y = (); x + y"#)?, engine.eval::<String>(r#"let x = "hello"; let y = (); x + y"#)?,
"hello Foo!" if cfg!(not(feature = "fast_ops")) {
"hello Foo!"
} else {
"hello"
}
); );
Ok(()) Ok(())

View File

@ -80,6 +80,7 @@ macro_rules! expand_enum {
#[export_module] #[export_module]
pub mod $module { pub mod $module {
$( $(
#[allow(non_upper_case_globals)]
pub const $variant: $typ = <$typ>::$variant; pub const $variant: $typ = <$typ>::$variant;
)* )*
} }
@ -127,7 +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]; 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]; hi(a, 2)")?, 6);
assert_eq!(engine.eval::<INT>("let a = [1, 2, 3]; test(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::<INT>("2 + 2")?,
if cfg!(not(feature = "fast_ops")) {
5
} else {
4
}
);
assert_eq!( assert_eq!(
engine.eval::<String>("let a = [1, 2, 3]; greet(test(a, 2))")?, engine.eval::<String>("let a = [1, 2, 3]; greet(test(a, 2))")?,
"6 kitties" "6 kitties"