Make Engine reentrant to prepare for parallel execution.

This commit is contained in:
Stephen Chung
2020-04-07 13:23:06 +08:00
parent e204ae1a2c
commit e795a50ae2
44 changed files with 415 additions and 404 deletions

View File

@@ -2,7 +2,7 @@ use rhai::{Engine, EvalAltResult};
#[test]
fn test_bool_op1() -> Result<(), EvalAltResult> {
let mut engine = Engine::new();
let engine = Engine::new();
assert_eq!(engine.eval::<bool>("true && (false || true)")?, true);
assert_eq!(engine.eval::<bool>("true & (false | true)")?, true);
@@ -12,7 +12,7 @@ fn test_bool_op1() -> Result<(), EvalAltResult> {
#[test]
fn test_bool_op2() -> Result<(), EvalAltResult> {
let mut engine = Engine::new();
let engine = Engine::new();
assert_eq!(engine.eval::<bool>("false && (false || true)")?, false);
assert_eq!(engine.eval::<bool>("false & (false | true)")?, false);
@@ -22,7 +22,7 @@ fn test_bool_op2() -> Result<(), EvalAltResult> {
#[test]
fn test_bool_op3() -> Result<(), EvalAltResult> {
let mut engine = Engine::new();
let engine = Engine::new();
assert!(engine.eval::<bool>("true && (false || 123)").is_err());
assert_eq!(engine.eval::<bool>("true && (true || 123)")?, true);
@@ -34,7 +34,7 @@ fn test_bool_op3() -> Result<(), EvalAltResult> {
#[test]
fn test_bool_op_short_circuit() -> Result<(), EvalAltResult> {
let mut engine = Engine::new();
let engine = Engine::new();
assert_eq!(
engine.eval::<bool>(
@@ -63,7 +63,7 @@ fn test_bool_op_short_circuit() -> Result<(), EvalAltResult> {
#[test]
fn test_bool_op_no_short_circuit1() {
let mut engine = Engine::new();
let engine = Engine::new();
assert!(engine
.eval::<bool>(
@@ -78,7 +78,7 @@ fn test_bool_op_no_short_circuit1() {
#[test]
fn test_bool_op_no_short_circuit2() {
let mut engine = Engine::new();
let engine = Engine::new();
assert!(engine
.eval::<bool>(