Fix closure test.

This commit is contained in:
Stephen Chung 2020-08-22 23:01:25 +08:00
parent 0ece75aba3
commit 177a0de23c
2 changed files with 8 additions and 7 deletions

View File

@ -2,7 +2,7 @@
use crate::any::{Dynamic, Variant}; use crate::any::{Dynamic, Variant};
use crate::engine::{Engine, Imports, State}; use crate::engine::{Engine, Imports, State};
use crate::error::{ParseError, ParseErrorType}; use crate::error::ParseError;
use crate::fn_native::{IteratorFn, SendSync}; use crate::fn_native::{IteratorFn, SendSync};
use crate::module::{FuncReturn, Module}; use crate::module::{FuncReturn, Module};
use crate::optimize::OptimizationLevel; use crate::optimize::OptimizationLevel;
@ -18,6 +18,7 @@ use crate::engine::{FN_IDX_GET, FN_IDX_SET};
#[cfg(not(feature = "no_object"))] #[cfg(not(feature = "no_object"))]
use crate::{ use crate::{
engine::{make_getter, make_setter, Map}, engine::{make_getter, make_setter, Map},
error::ParseErrorType,
fn_register::{RegisterFn, RegisterResultFn}, fn_register::{RegisterFn, RegisterResultFn},
token::Token, token::Token,
}; };
@ -34,7 +35,6 @@ use crate::optimize::optimize_into_ast;
use crate::stdlib::{ use crate::stdlib::{
any::{type_name, TypeId}, any::{type_name, TypeId},
boxed::Box, boxed::Box,
string::ToString,
}; };
#[cfg(not(feature = "no_optimize"))] #[cfg(not(feature = "no_optimize"))]
@ -944,8 +944,8 @@ impl Engine {
["#", json_text] ["#", json_text]
} else { } else {
return Err(ParseErrorType::MissingToken( return Err(ParseErrorType::MissingToken(
Token::LeftBrace.syntax().to_string(), Token::LeftBrace.syntax().into(),
"to start a JSON object hash".to_string(), "to start a JSON object hash".into(),
) )
.into_err(Position::new(1, (json.len() - json_text.len() + 1) as u16)) .into_err(Position::new(1, (json.len() - json_text.len() + 1) as u16))
.into()); .into());

View File

@ -1,12 +1,13 @@
#![cfg(not(feature = "no_function"))] #![cfg(not(feature = "no_function"))]
use rhai::{ use rhai::{Dynamic, Engine, EvalAltResult, FnPtr, Module, ParseErrorType, RegisterFn, Scope, INT};
Dynamic, Engine, EvalAltResult, FnPtr, Map, Module, ParseErrorType, RegisterFn, Scope, INT,
};
use std::any::TypeId; use std::any::TypeId;
use std::cell::RefCell; use std::cell::RefCell;
use std::mem::take; use std::mem::take;
use std::rc::Rc; use std::rc::Rc;
#[cfg(not(feature = "no_object"))]
use rhai::Map;
#[test] #[test]
fn test_fn_ptr_curry_call() -> Result<(), Box<EvalAltResult>> { fn test_fn_ptr_curry_call() -> Result<(), Box<EvalAltResult>> {
let mut engine = Engine::new(); let mut engine = Engine::new();