Better convert LexError to ParseError.

This commit is contained in:
Stephen Chung
2020-06-14 16:56:36 +08:00
parent b51930031b
commit 0c6a939c66
4 changed files with 44 additions and 51 deletions

View File

@@ -14,12 +14,12 @@ fn test_max_string_size() -> Result<(), Box<EvalAltResult>> {
assert!(matches!(
engine.compile(r#"let x = "hello, world!";"#).expect_err("should error"),
ParseError(x, _) if *x == ParseErrorType::BadInput("Length of string literal exceeds the maximum limit (10)".to_string())
ParseError(x, _) if *x == ParseErrorType::LiteralTooLarge("Length of string literal".to_string(), 10)
));
assert!(matches!(
engine.compile(r#"let x = "朝に紅顔、暮に白骨";"#).expect_err("should error"),
ParseError(x, _) if *x == ParseErrorType::BadInput("Length of string literal exceeds the maximum limit (10)".to_string())
ParseError(x, _) if *x == ParseErrorType::LiteralTooLarge("Length of string literal".to_string(), 10)
));
assert!(matches!(