Add ParseError:err_type and ParseError::position.

This commit is contained in:
Stephen Chung
2022-07-29 09:42:30 +08:00
parent 6fab9f5b63
commit ea38185cac
19 changed files with 147 additions and 104 deletions

View File

@@ -132,43 +132,43 @@ fn test_map_index_types() -> Result<(), Box<EvalAltResult>> {
engine.compile(r#"#{a:1, b:2, c:3}["a"]['x']"#)?;
assert!(matches!(
*engine
engine
.compile("#{a:1, b:2, c:3}['x']")
.expect_err("should error")
.0,
.err_type(),
ParseErrorType::MalformedIndexExpr(..)
));
assert!(matches!(
*engine
engine
.compile("#{a:1, b:2, c:3}[1]")
.expect_err("should error")
.0,
.err_type(),
ParseErrorType::MalformedIndexExpr(..)
));
#[cfg(not(feature = "no_float"))]
assert!(matches!(
*engine
engine
.compile("#{a:1, b:2, c:3}[123.456]")
.expect_err("should error")
.0,
.err_type(),
ParseErrorType::MalformedIndexExpr(..)
));
assert!(matches!(
*engine
engine
.compile("#{a:1, b:2, c:3}[()]")
.expect_err("should error")
.0,
.err_type(),
ParseErrorType::MalformedIndexExpr(..)
));
assert!(matches!(
*engine
engine
.compile("#{a:1, b:2, c:3}[true && false]")
.expect_err("should error")
.0,
.err_type(),
ParseErrorType::MalformedIndexExpr(..)
));