Fix test formatting.

This commit is contained in:
Stephen Chung 2021-03-27 18:08:34 +08:00
parent 47588f9784
commit ea970631ff
10 changed files with 45 additions and 45 deletions

View File

@ -324,7 +324,7 @@ fn test_closures_external() -> Result<(), Box<EvalAltResult>> {
r#"
let test = "hello";
|x| test + x
"#,
"#,
)?;
// Save the function pointer together with captured variables

View File

@ -67,7 +67,7 @@ fn test_expressions_eval() -> Result<(), Box<EvalAltResult>> {
let result: bool = engine.eval_expression_with_scope(
&mut scope,
r#"
agent.age > 10 && agent.gender == "male"
agent.age > 10 && agent.gender == "male"
"#,
)?;

View File

@ -242,19 +242,19 @@ fn test_function_is_def() -> Result<(), Box<EvalAltResult>> {
r#"
fn foo(x) { x + 1 }
is_def_fn("foo", 1)
"#
"#
)?);
assert!(!engine.eval::<bool>(
r#"
fn foo(x) { x + 1 }
is_def_fn("bar", 1)
"#
"#
)?);
assert!(!engine.eval::<bool>(
r#"
fn foo(x) { x + 1 }
is_def_fn("foo", 0)
"#
"#
)?);
Ok(())

View File

@ -20,7 +20,7 @@ fn test_if() -> Result<(), Box<EvalAltResult>> {
else if false { 77 }
else if false { 88 }
else { 44 }
"
"
)?,
44
);
@ -38,7 +38,7 @@ fn test_if_expr() -> Result<(), Box<EvalAltResult>> {
let x = 42;
let y = 1 + if x > 40 { 100 } else { 0 } / x;
y
"
"
)?,
3
);

View File

@ -21,7 +21,7 @@ fn test_loop() -> Result<(), Box<EvalAltResult>> {
}
return x;
"
"
)?,
21
);

View File

@ -43,24 +43,24 @@ fn test_max_operations_functions() -> Result<(), Box<EvalAltResult>> {
engine.eval::<()>(
r#"
print("Test1");
let x = 0;
print("Test1");
let x = 0;
while x < 28 {
print(x);
x += 1;
}
"#,
while x < 28 {
print(x);
x += 1;
}
"#,
)?;
#[cfg(not(feature = "no_function"))]
engine.eval::<()>(
r#"
print("Test2");
fn inc(x) { x + 1 }
let x = 0;
while x < 20 { x = inc(x); }
"#,
print("Test2");
fn inc(x) { x + 1 }
let x = 0;
while x < 20 { x = inc(x); }
"#,
)?;
#[cfg(not(feature = "no_function"))]
@ -76,7 +76,7 @@ fn test_max_operations_functions() -> Result<(), Box<EvalAltResult>> {
print(x);
x = inc(x);
}
"#,
"#,
)
.expect_err("should error"),
EvalAltResult::ErrorTooManyOperations(_)
@ -103,7 +103,7 @@ fn test_max_operations_eval() -> Result<(), Box<EvalAltResult>> {
r#"
let script = "for x in range(0, 500) {}";
eval(script);
"#
"#
)
.expect_err("should error"),
EvalAltResult::ErrorInFunctionCall(_, _, err, _) if matches!(*err, EvalAltResult::ErrorTooManyOperations(_))

View File

@ -65,24 +65,24 @@ fn test_stack_overflow_parsing() -> Result<(), Box<EvalAltResult>> {
1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 0 +
1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 0 +
1 + 2 + 3 + 4 + 5 + 6 + 7 + 8
",
",
)?;
assert_eq!(
*engine
.compile(
r"
1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 0 +
1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 0 +
1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 0 +
1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 0 +
1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 0 +
1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 0 +
1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 0 +
1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 0 +
1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 0 +
1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9
"
1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 0 +
1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 0 +
1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 0 +
1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 0 +
1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 0 +
1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 0 +
1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 0 +
1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 0 +
1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 0 +
1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9
"
)
.expect_err("should error")
.0,

View File

@ -23,7 +23,7 @@ fn test_timestamp() -> Result<(), Box<EvalAltResult>> {
let x = 10_000;
while x > 0 { x -= 1; }
elapsed(time)
"#
"#
)? < 10.0
);
@ -35,7 +35,7 @@ fn test_timestamp() -> Result<(), Box<EvalAltResult>> {
let x = 10_000;
while x > 0 { x -= 1; }
elapsed(time)
"#
"#
)? < 10
);
@ -62,7 +62,7 @@ fn test_timestamp_op() -> Result<(), Box<EvalAltResult>> {
let time1 = timestamp();
let time2 = time1 + 123.45;
time2 - time1
"#
"#
)? - 123.45)
.abs()
< 0.001
@ -75,7 +75,7 @@ fn test_timestamp_op() -> Result<(), Box<EvalAltResult>> {
let time1 = timestamp();
let time2 = time1 - 123.45;
time1 - time2
"#
"#
)? - 123.45)
.abs()
< 0.001
@ -88,7 +88,7 @@ fn test_timestamp_op() -> Result<(), Box<EvalAltResult>> {
let time1 = timestamp();
let time2 = time1 + 42;
time2 - time1
"#
"#
)?,
42
);
@ -100,7 +100,7 @@ fn test_timestamp_op() -> Result<(), Box<EvalAltResult>> {
let time1 = timestamp();
let time2 = time1 - 42;
time1 - time2
"#
"#
)?,
42
);

View File

@ -27,19 +27,19 @@ fn test_var_is_def() -> Result<(), Box<EvalAltResult>> {
r#"
let x = 42;
is_def_var("x")
"#
"#
)?);
assert!(!engine.eval::<bool>(
r#"
let x = 42;
is_def_var("y")
"#
"#
)?);
assert!(engine.eval::<bool>(
r#"
const x = 42;
is_def_var("x")
"#
"#
)?);
Ok(())

View File

@ -17,7 +17,7 @@ fn test_while() -> Result<(), Box<EvalAltResult>> {
}
x
",
",
)?,
6
);
@ -42,7 +42,7 @@ fn test_do() -> Result<(), Box<EvalAltResult>> {
} while x < 10;
x
",
",
)?,
6
);