Change eval<()> to run.

This commit is contained in:
Stephen Chung
2022-01-10 13:26:33 +08:00
parent 1e0d46fc13
commit d15470fd4b
8 changed files with 18 additions and 20 deletions

View File

@@ -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
));