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

@@ -16,7 +16,7 @@ fn test_max_string_size() -> Result<(), Box<EvalAltResult>> {
*engine
.compile(r#"let x = "hello, world!";"#)
.expect_err("should error")
.0,
.err_type(),
ParseErrorType::LiteralTooLarge("Length of string literal".to_string(), 10)
);
@@ -24,7 +24,7 @@ fn test_max_string_size() -> Result<(), Box<EvalAltResult>> {
*engine
.compile(r#"let x = "朝に紅顔、暮に白骨";"#)
.expect_err("should error")
.0,
.err_type(),
ParseErrorType::LiteralTooLarge("Length of string literal".to_string(), 10)
);
@@ -84,7 +84,7 @@ fn test_max_array_size() -> Result<(), Box<EvalAltResult>> {
*engine
.compile("let x = [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15];")
.expect_err("should error")
.0,
.err_type(),
ParseErrorType::LiteralTooLarge("Size of array literal".to_string(), 10)
);
@@ -266,7 +266,7 @@ fn test_max_map_size() -> Result<(), Box<EvalAltResult>> {
"let x = #{a:1,b:2,c:3,d:4,e:5,f:6,g:7,h:8,i:9,j:10,k:11,l:12,m:13,n:14,o:15};"
)
.expect_err("should error")
.0,
.err_type(),
ParseErrorType::LiteralTooLarge(
"Number of properties in object map literal".to_string(),
10