From d15470fd4bd118858e5af5d3ff217a2e136252c2 Mon Sep 17 00:00:00 2001 From: Stephen Chung Date: Mon, 10 Jan 2022 13:26:33 +0800 Subject: [PATCH] Change eval<()> to run. --- tests/comments.rs | 2 +- tests/maps.rs | 2 +- tests/modules.rs | 2 +- tests/operations.rs | 18 ++++++++---------- tests/stack.rs | 2 +- tests/switch.rs | 2 +- tests/throw.rs | 6 +++--- tests/unit.rs | 4 ++-- 8 files changed, 18 insertions(+), 20 deletions(-) diff --git a/tests/comments.rs b/tests/comments.rs index e0a2d2a2..38da0c1f 100644 --- a/tests/comments.rs +++ b/tests/comments.rs @@ -21,7 +21,7 @@ fn test_comments() -> Result<(), Box> { 42 ); - assert_eq!(engine.eval::<()>("/* Hello world */")?, ()); + assert_eq!(engine.run("/* Hello world */")?, ()); Ok(()) } diff --git a/tests/maps.rs b/tests/maps.rs index 10a79591..a4757423 100644 --- a/tests/maps.rs +++ b/tests/maps.rs @@ -36,7 +36,7 @@ fn test_map_indexing() -> Result<(), Box> { 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"))] assert_eq!( diff --git a/tests/modules.rs b/tests/modules.rs index b1587f10..6f8e56b7 100644 --- a/tests/modules.rs +++ b/tests/modules.rs @@ -243,7 +243,7 @@ fn test_module_resolver() -> Result<(), Box> { engine.set_max_modules(1000); #[cfg(not(feature = "no_function"))] - engine.eval::<()>( + engine.run( r#" fn foo() { import "hello" as h; diff --git a/tests/operations.rs b/tests/operations.rs index 13c0cb48..5114ab05 100644 --- a/tests/operations.rs +++ b/tests/operations.rs @@ -15,18 +15,16 @@ fn test_max_operations() -> Result<(), Box> { 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> { None }); - engine.eval::<()>( + engine.run( r#" print("Test1"); let x = 0; @@ -56,7 +54,7 @@ fn test_max_operations_functions() -> Result<(), Box> { )?; #[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> { #[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> { 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> { 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 )); diff --git a/tests/stack.rs b/tests/stack.rs index febdcbbd..c2a8d21d 100644 --- a/tests/stack.rs +++ b/tests/stack.rs @@ -21,7 +21,7 @@ fn test_stack_overflow_fn_calls() -> Result<(), Box> { #[cfg(not(feature = "unchecked"))] assert!(matches!( *engine - .eval::<()>(&format!( + .run(&format!( " fn foo(n) {{ if n == 0 {{ 0 }} else {{ n + foo(n-1) }} }} foo({}) diff --git a/tests/switch.rs b/tests/switch.rs index b3afbb6f..6d91c809 100644 --- a/tests/switch.rs +++ b/tests/switch.rs @@ -11,7 +11,7 @@ fn test_switch() -> Result<(), Box> { 'a' ); assert_eq!( - engine.eval::<()>("switch 3 { 1 => (), 2 => 'a', 42 => true }")?, + engine.run("switch 3 { 1 => (), 2 => 'a', 42 => true }")?, () ); assert_eq!( diff --git a/tests/throw.rs b/tests/throw.rs index 2ef82dd2..e0617559 100644 --- a/tests/throw.rs +++ b/tests/throw.rs @@ -5,12 +5,12 @@ fn test_throw() { let engine = Engine::new(); 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 )); assert!(matches!( - *engine.eval::<()>(r#"throw"#).expect_err("expects error"), + *engine.run(r#"throw"#).expect_err("expects error"), EvalAltResult::ErrorRuntime(s, _) if s.is::<()>() )); } @@ -88,7 +88,7 @@ fn test_try_catch() -> Result<(), Box> { #[cfg(not(feature = "unchecked"))] assert!(matches!( *engine - .eval::<()>("try { 42/0; } catch { throw; }") + .run("try { 42/0; } catch { throw; }") .expect_err("expects error"), EvalAltResult::ErrorArithmetic(_, _) )); diff --git a/tests/unit.rs b/tests/unit.rs index 2777ae54..edfcf61c 100644 --- a/tests/unit.rs +++ b/tests/unit.rs @@ -3,7 +3,7 @@ use rhai::{Engine, EvalAltResult}; #[test] fn test_unit() -> Result<(), Box> { let engine = Engine::new(); - engine.eval::<()>("let x = (); x")?; + engine.run("let x = (); x")?; Ok(()) } @@ -17,6 +17,6 @@ fn test_unit_eq() -> Result<(), Box> { #[test] fn test_unit_with_spaces() -> Result<(), Box> { let engine = Engine::new(); - engine.eval::<()>("let x = ( ); x")?; + engine.run("let x = ( ); x")?; Ok(()) }