Fix tests.

This commit is contained in:
Stephen Chung 2020-08-06 00:24:25 +08:00
parent fff08d29b6
commit 41b41ff834
2 changed files with 6 additions and 6 deletions

View File

@ -5,16 +5,16 @@ use std::sync::{Arc, Mutex, RwLock};
/// Simulate a command object. /// Simulate a command object.
struct Command { struct Command {
/// Simulate an external state. /// Simulate an external state.
state: i64, state: INT,
} }
impl Command { impl Command {
/// Do some action. /// Do some action.
pub fn action(&mut self, val: i64) { pub fn action(&mut self, val: INT) {
self.state = val; self.state = val;
} }
/// Get current value. /// Get current value.
pub fn get(&self) -> i64 { pub fn get(&self) -> INT {
self.state self.state
} }
} }
@ -39,7 +39,7 @@ fn test_side_effects_command() -> Result<(), Box<EvalAltResult>> {
// Register type. // Register type.
engine.register_type_with_name::<API>("CommandType"); engine.register_type_with_name::<API>("CommandType");
engine.register_fn("action", |api: &mut API, x: i64| { engine.register_fn("action", |api: &mut API, x: INT| {
let mut command = api.lock().unwrap(); let mut command = api.lock().unwrap();
let val = command.get(); let val = command.get();
command.action(val + x); command.action(val + x);

View File

@ -1,5 +1,5 @@
#![cfg(not(feature = "unchecked"))] #![cfg(not(feature = "unchecked"))]
use rhai::{Engine, EvalAltResult, ParseError, ParseErrorType}; use rhai::{Engine, EvalAltResult, ParseError, ParseErrorType, INT};
#[test] #[test]
#[cfg(not(feature = "no_function"))] #[cfg(not(feature = "no_function"))]
@ -7,7 +7,7 @@ fn test_stack_overflow_fn_calls() -> Result<(), Box<EvalAltResult>> {
let engine = Engine::new(); let engine = Engine::new();
assert_eq!( assert_eq!(
engine.eval::<i64>( engine.eval::<INT>(
r" r"
fn foo(n) { if n <= 1 { 0 } else { n + foo(n-1) } } fn foo(n) { if n <= 1 { 0 } else { n + foo(n-1) } }
foo(8) foo(8)