Change eval<()> to run.
This commit is contained in:
parent
1e0d46fc13
commit
d15470fd4b
@ -21,7 +21,7 @@ fn test_comments() -> Result<(), Box<EvalAltResult>> {
|
||||
42
|
||||
);
|
||||
|
||||
assert_eq!(engine.eval::<()>("/* Hello world */")?, ());
|
||||
assert_eq!(engine.run("/* Hello world */")?, ());
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
@ -36,7 +36,7 @@ fn test_map_indexing() -> Result<(), Box<EvalAltResult>> {
|
||||
5
|
||||
);
|
||||
|
||||
engine.eval::<()>("let y = #{a: 1, b: 2, c: 3}; y.z")?;
|
||||
engine.run("let y = #{a: 1, b: 2, c: 3}; y.z")?;
|
||||
|
||||
#[cfg(not(feature = "no_index"))]
|
||||
assert_eq!(
|
||||
|
@ -243,7 +243,7 @@ fn test_module_resolver() -> Result<(), Box<EvalAltResult>> {
|
||||
engine.set_max_modules(1000);
|
||||
|
||||
#[cfg(not(feature = "no_function"))]
|
||||
engine.eval::<()>(
|
||||
engine.run(
|
||||
r#"
|
||||
fn foo() {
|
||||
import "hello" as h;
|
||||
|
@ -15,18 +15,16 @@ fn test_max_operations() -> Result<(), Box<EvalAltResult>> {
|
||||
None
|
||||
});
|
||||
|
||||
engine.eval::<()>("let x = 0; while x < 20 { x += 1; }")?;
|
||||
engine.run("let x = 0; while x < 20 { x += 1; }")?;
|
||||
|
||||
assert!(matches!(
|
||||
*engine
|
||||
.eval::<()>("for x in 0..500 {}")
|
||||
.expect_err("should error"),
|
||||
*engine.run("for x in 0..500 {}").expect_err("should error"),
|
||||
EvalAltResult::ErrorTooManyOperations(_)
|
||||
));
|
||||
|
||||
engine.set_max_operations(0);
|
||||
|
||||
engine.eval::<()>("for x in 0..10000 {}")?;
|
||||
engine.run("for x in 0..10000 {}")?;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
@ -43,7 +41,7 @@ fn test_max_operations_functions() -> Result<(), Box<EvalAltResult>> {
|
||||
None
|
||||
});
|
||||
|
||||
engine.eval::<()>(
|
||||
engine.run(
|
||||
r#"
|
||||
print("Test1");
|
||||
let x = 0;
|
||||
@ -56,7 +54,7 @@ fn test_max_operations_functions() -> Result<(), Box<EvalAltResult>> {
|
||||
)?;
|
||||
|
||||
#[cfg(not(feature = "no_function"))]
|
||||
engine.eval::<()>(
|
||||
engine.run(
|
||||
r#"
|
||||
print("Test2");
|
||||
fn inc(x) { x + 1 }
|
||||
@ -68,7 +66,7 @@ fn test_max_operations_functions() -> Result<(), Box<EvalAltResult>> {
|
||||
#[cfg(not(feature = "no_function"))]
|
||||
assert!(matches!(
|
||||
*engine
|
||||
.eval::<()>(
|
||||
.run(
|
||||
r#"
|
||||
print("Test3");
|
||||
fn inc(x) { x + 1 }
|
||||
@ -101,7 +99,7 @@ fn test_max_operations_eval() -> Result<(), Box<EvalAltResult>> {
|
||||
|
||||
assert!(matches!(
|
||||
*engine
|
||||
.eval::<()>(
|
||||
.run(
|
||||
r#"
|
||||
let script = "for x in 0..500 {}";
|
||||
eval(script);
|
||||
@ -131,7 +129,7 @@ fn test_max_operations_progress() -> Result<(), Box<EvalAltResult>> {
|
||||
|
||||
assert!(matches!(
|
||||
*engine
|
||||
.eval::<()>("for x in 0..500 {}")
|
||||
.run("for x in 0..500 {}")
|
||||
.expect_err("should error"),
|
||||
EvalAltResult::ErrorTerminated(x, _) if x.as_int()? == 42
|
||||
));
|
||||
|
@ -21,7 +21,7 @@ fn test_stack_overflow_fn_calls() -> Result<(), Box<EvalAltResult>> {
|
||||
#[cfg(not(feature = "unchecked"))]
|
||||
assert!(matches!(
|
||||
*engine
|
||||
.eval::<()>(&format!(
|
||||
.run(&format!(
|
||||
"
|
||||
fn foo(n) {{ if n == 0 {{ 0 }} else {{ n + foo(n-1) }} }}
|
||||
foo({})
|
||||
|
@ -11,7 +11,7 @@ fn test_switch() -> Result<(), Box<EvalAltResult>> {
|
||||
'a'
|
||||
);
|
||||
assert_eq!(
|
||||
engine.eval::<()>("switch 3 { 1 => (), 2 => 'a', 42 => true }")?,
|
||||
engine.run("switch 3 { 1 => (), 2 => 'a', 42 => true }")?,
|
||||
()
|
||||
);
|
||||
assert_eq!(
|
||||
|
@ -5,12 +5,12 @@ fn test_throw() {
|
||||
let engine = Engine::new();
|
||||
|
||||
assert!(matches!(
|
||||
*engine.eval::<()>("if true { throw 42 }").expect_err("expects error"),
|
||||
*engine.run("if true { throw 42 }").expect_err("expects error"),
|
||||
EvalAltResult::ErrorRuntime(s, _) if s.as_int().unwrap() == 42
|
||||
));
|
||||
|
||||
assert!(matches!(
|
||||
*engine.eval::<()>(r#"throw"#).expect_err("expects error"),
|
||||
*engine.run(r#"throw"#).expect_err("expects error"),
|
||||
EvalAltResult::ErrorRuntime(s, _) if s.is::<()>()
|
||||
));
|
||||
}
|
||||
@ -88,7 +88,7 @@ fn test_try_catch() -> Result<(), Box<EvalAltResult>> {
|
||||
#[cfg(not(feature = "unchecked"))]
|
||||
assert!(matches!(
|
||||
*engine
|
||||
.eval::<()>("try { 42/0; } catch { throw; }")
|
||||
.run("try { 42/0; } catch { throw; }")
|
||||
.expect_err("expects error"),
|
||||
EvalAltResult::ErrorArithmetic(_, _)
|
||||
));
|
||||
|
@ -3,7 +3,7 @@ use rhai::{Engine, EvalAltResult};
|
||||
#[test]
|
||||
fn test_unit() -> Result<(), Box<EvalAltResult>> {
|
||||
let engine = Engine::new();
|
||||
engine.eval::<()>("let x = (); x")?;
|
||||
engine.run("let x = (); x")?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@ -17,6 +17,6 @@ fn test_unit_eq() -> Result<(), Box<EvalAltResult>> {
|
||||
#[test]
|
||||
fn test_unit_with_spaces() -> Result<(), Box<EvalAltResult>> {
|
||||
let engine = Engine::new();
|
||||
engine.eval::<()>("let x = ( ); x")?;
|
||||
engine.run("let x = ( ); x")?;
|
||||
Ok(())
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user