Use u64 for operations counter.

This commit is contained in:
Stephen Chung
2020-05-19 10:08:27 +08:00
parent 1824dced69
commit 6b8c6bda42
4 changed files with 31 additions and 36 deletions

View File

@@ -86,14 +86,14 @@ fn test_module_resolver() -> Result<(), Box<EvalAltResult>> {
*engine
.eval::<INT>(
r#"
let x = 0;
let sum = 0;
for x in range(0, 10) {
import "hello" as h;
x += h::answer;
sum += h::answer;
}
x
sum
"#
)
.expect_err("should error"),
@@ -105,18 +105,18 @@ fn test_module_resolver() -> Result<(), Box<EvalAltResult>> {
*engine
.eval::<INT>(
r#"
let x = 0;
let sum = 0;
fn foo() {
import "hello" as h;
x += h::answer;
sum += h::answer;
}
for x in range(0, 10) {
foo();
}
x
sum
"#
)
.expect_err("should error"),

View File

@@ -16,19 +16,14 @@ fn test_stack_overflow_fn_calls() -> Result<(), Box<EvalAltResult>> {
);
#[cfg(not(feature = "unchecked"))]
match engine.eval::<()>(
assert!(matches!(
*engine.eval::<()>(
r"
fn foo(n) { if n == 0 { 0 } else { n + foo(n-1) } }
foo(1000)
",
) {
Ok(_) => panic!("should be stack overflow"),
Err(err) => match *err {
EvalAltResult::ErrorInFunctionCall(name, _, _)
if name.starts_with("foo > foo > foo") => {}
_ => panic!("should be stack overflow"),
},
}
").expect_err("should error"),
EvalAltResult::ErrorInFunctionCall(name, _, _) if name.starts_with("foo > foo > foo")
));
Ok(())
}