Improve treatment of disabled symbols and custom symbols.

This commit is contained in:
Stephen Chung
2020-07-17 14:50:23 +08:00
parent d119e13b79
commit 3ae7cf4018
9 changed files with 110 additions and 77 deletions

View File

@@ -7,8 +7,11 @@ fn test_tokens_disabled() {
engine.disable_symbol("if"); // disable the 'if' keyword
assert!(matches!(
*engine.compile("let x = if true { 42 } else { 0 };").expect_err("should error").0,
ParseErrorType::MissingToken(ref token, _) if token == ";"
*engine
.compile("let x = if true { 42 } else { 0 };")
.expect_err("should error")
.0,
ParseErrorType::Reserved(err) if err == "if"
));
engine.disable_symbol("+="); // disable the '+=' operator