Remove no_stdlib feature in favor of Engine::new_raw().
This commit is contained in:
@@ -13,42 +13,39 @@ fn test_arrays() -> Result<(), EvalAltResult> {
|
||||
);
|
||||
assert!(engine.eval::<bool>("let y = [1, 2, 3]; 2 in y")?);
|
||||
|
||||
#[cfg(not(feature = "no_stdlib"))]
|
||||
{
|
||||
assert_eq!(
|
||||
engine.eval::<INT>(
|
||||
r"
|
||||
assert_eq!(
|
||||
engine.eval::<INT>(
|
||||
r"
|
||||
let x = [1, 2, 3];
|
||||
let y = [4, 5];
|
||||
x.append(y);
|
||||
x.len()
|
||||
"
|
||||
)?,
|
||||
5
|
||||
);
|
||||
assert_eq!(
|
||||
engine.eval::<INT>(
|
||||
r"
|
||||
)?,
|
||||
5
|
||||
);
|
||||
assert_eq!(
|
||||
engine.eval::<INT>(
|
||||
r"
|
||||
let x = [1, 2, 3];
|
||||
x += [4, 5];
|
||||
x.len()
|
||||
"
|
||||
)?,
|
||||
5
|
||||
);
|
||||
assert_eq!(
|
||||
engine
|
||||
.eval::<Array>(
|
||||
r"
|
||||
)?,
|
||||
5
|
||||
);
|
||||
assert_eq!(
|
||||
engine
|
||||
.eval::<Array>(
|
||||
r"
|
||||
let x = [1, 2, 3];
|
||||
let y = [4, 5];
|
||||
x + y
|
||||
"
|
||||
)?
|
||||
.len(),
|
||||
5
|
||||
);
|
||||
}
|
||||
)?
|
||||
.len(),
|
||||
5
|
||||
);
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
@@ -33,42 +33,39 @@ fn test_map_indexing() -> Result<(), EvalAltResult> {
|
||||
assert!(engine.eval::<bool>("let y = #{a: 1, b: 2, c: 3}; 'b' in y")?);
|
||||
assert!(!engine.eval::<bool>(r#"let y = #{a: 1, b: 2, c: 3}; "z" in y"#)?);
|
||||
|
||||
#[cfg(not(feature = "no_stdlib"))]
|
||||
{
|
||||
assert_eq!(
|
||||
engine.eval::<INT>(
|
||||
assert_eq!(
|
||||
engine.eval::<INT>(
|
||||
r"
|
||||
let x = #{a: 1, b: 2, c: 3};
|
||||
let y = #{b: 42, d: 9};
|
||||
x.mixin(y);
|
||||
x.len() + x.b
|
||||
"
|
||||
)?,
|
||||
46
|
||||
);
|
||||
assert_eq!(
|
||||
engine.eval::<INT>(
|
||||
r"
|
||||
let x = #{a: 1, b: 2, c: 3};
|
||||
x += #{b: 42, d: 9};
|
||||
x.len() + x.b
|
||||
"
|
||||
)?,
|
||||
46
|
||||
);
|
||||
assert_eq!(
|
||||
engine
|
||||
.eval::<Map>(
|
||||
r"
|
||||
let x = #{a: 1, b: 2, c: 3};
|
||||
let y = #{b: 42, d: 9};
|
||||
x.mixin(y);
|
||||
x.len() + x.b
|
||||
x + y
|
||||
"
|
||||
)?,
|
||||
46
|
||||
);
|
||||
assert_eq!(
|
||||
engine.eval::<INT>(
|
||||
r"
|
||||
let x = #{a: 1, b: 2, c: 3};
|
||||
x += #{b: 42, d: 9};
|
||||
x.len() + x.b
|
||||
"
|
||||
)?,
|
||||
46
|
||||
);
|
||||
assert_eq!(
|
||||
engine
|
||||
.eval::<Map>(
|
||||
r"
|
||||
let x = #{a: 1, b: 2, c: 3};
|
||||
let y = #{b: 42, d: 9};
|
||||
x + y
|
||||
"
|
||||
)?
|
||||
.len(),
|
||||
4
|
||||
);
|
||||
}
|
||||
)?
|
||||
.len(),
|
||||
4
|
||||
);
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
@@ -1,12 +1,11 @@
|
||||
use rhai::{Engine, EvalAltResult, RegisterFn, INT};
|
||||
|
||||
#[test]
|
||||
#[cfg(not(feature = "no_stdlib"))]
|
||||
fn test_mismatched_op() {
|
||||
let engine = Engine::new();
|
||||
|
||||
assert!(
|
||||
matches!(engine.eval::<INT>(r#"60 + "hello""#).expect_err("expects error"),
|
||||
matches!(engine.eval::<INT>(r#""hello, " + "world!""#).expect_err("expects error"),
|
||||
EvalAltResult::ErrorMismatchOutputType(err, _) if err == "string")
|
||||
);
|
||||
}
|
||||
|
@@ -1,3 +1,4 @@
|
||||
#![cfg(not(feature = "no_function"))]
|
||||
use rhai::{Engine, EvalAltResult};
|
||||
|
||||
#[test]
|
||||
|
@@ -22,12 +22,12 @@ fn test_string() -> Result<(), EvalAltResult> {
|
||||
#[cfg(not(feature = "no_stdlib"))]
|
||||
assert_eq!(engine.eval::<String>(r#""foo" + 123"#)?, "foo123");
|
||||
|
||||
#[cfg(not(feature = "no_stdlib"))]
|
||||
assert_eq!(engine.eval::<String>("(42).to_string()")?, "42");
|
||||
|
||||
#[cfg(not(feature = "no_float"))]
|
||||
#[cfg(not(feature = "no_stdlib"))]
|
||||
assert_eq!(engine.eval::<String>(r#""foo" + 123.4556"#)?, "foo123.4556");
|
||||
|
||||
#[cfg(not(feature = "no_stdlib"))]
|
||||
assert_eq!(engine.eval::<String>("(42).to_string()")?, "42");
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
Reference in New Issue
Block a user