Merge branch 'master' into plugins_dev
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
#![cfg(not(feature = "no_object"))]
|
||||
|
||||
use rhai::{Engine, EvalAltResult, Map, Scope, INT};
|
||||
use rhai::{Engine, EvalAltResult, Map, ParseErrorType, Scope, INT};
|
||||
|
||||
#[test]
|
||||
fn test_map_indexing() -> Result<(), Box<EvalAltResult>> {
|
||||
@@ -182,6 +182,14 @@ fn test_map_json() -> Result<(), Box<EvalAltResult>> {
|
||||
);
|
||||
}
|
||||
|
||||
engine.parse_json(&format!("#{}", json), true)?;
|
||||
|
||||
assert!(matches!(
|
||||
*engine.parse_json(" 123", true).expect_err("should error"),
|
||||
EvalAltResult::ErrorParsing(ParseErrorType::MissingToken(token, _), pos)
|
||||
if token == "{" && pos.position() == Some(4)
|
||||
));
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
@@ -94,6 +94,31 @@ fn test_module_resolver() -> Result<(), Box<EvalAltResult>> {
|
||||
42
|
||||
);
|
||||
|
||||
assert_eq!(
|
||||
engine.eval::<INT>(
|
||||
r#"
|
||||
import "hello" as h1;
|
||||
import "hello" as h2;
|
||||
let x = 42;
|
||||
h1::sum(x, -10, 3, 7)
|
||||
"#
|
||||
)?,
|
||||
42
|
||||
);
|
||||
|
||||
assert_eq!(
|
||||
engine.eval::<INT>(
|
||||
r#"
|
||||
import "hello" as h1;
|
||||
import "hello" as h2;
|
||||
let x = 42;
|
||||
h1::sum(x, 0, 0, 0);
|
||||
x
|
||||
"#
|
||||
)?,
|
||||
42
|
||||
);
|
||||
|
||||
assert_eq!(
|
||||
engine.eval::<INT>(
|
||||
r#"
|
||||
|
Reference in New Issue
Block a user