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