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#" r#"
let test = "hello"; let test = "hello";
|x| test + x |x| test + x
"#, "#,
)?; )?;
// Save the function pointer together with captured variables // 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( let result: bool = engine.eval_expression_with_scope(
&mut scope, &mut scope,
r#" 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#" r#"
fn foo(x) { x + 1 } fn foo(x) { x + 1 }
is_def_fn("foo", 1) is_def_fn("foo", 1)
"# "#
)?); )?);
assert!(!engine.eval::<bool>( assert!(!engine.eval::<bool>(
r#" r#"
fn foo(x) { x + 1 } fn foo(x) { x + 1 }
is_def_fn("bar", 1) is_def_fn("bar", 1)
"# "#
)?); )?);
assert!(!engine.eval::<bool>( assert!(!engine.eval::<bool>(
r#" r#"
fn foo(x) { x + 1 } fn foo(x) { x + 1 }
is_def_fn("foo", 0) is_def_fn("foo", 0)
"# "#
)?); )?);
Ok(()) Ok(())

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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