From 82377176d9a37e4ade8b40c831d3d79ec60276c9 Mon Sep 17 00:00:00 2001 From: Filip Sandborg-Olsen Date: Tue, 11 Jun 2024 01:44:37 +0200 Subject: [PATCH] parser/lexer: add tests for special identifiers --- parser/lexer_test.go | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/parser/lexer_test.go b/parser/lexer_test.go index faa98a48..7e1e5faf 100644 --- a/parser/lexer_test.go +++ b/parser/lexer_test.go @@ -351,6 +351,21 @@ Second line \ token.RIGHT_BRACKET, "", 6, ) + // Identifier from Unicode Nl + test("\u16ee", + token.IDENTIFIER, "ᛮ", 1, + ) + + // Identifier from Unicode Other_ID_Start + test("\u212e", + token.IDENTIFIER, "℮", 1, + ) + + // Using char from ID_Continue after valid start char + test("a\u0300", + token.IDENTIFIER, "à", 1, + ) + // ILLEGAL test(`3ea`, @@ -383,5 +398,15 @@ Second line \ token.STRING, "\"\\x0G\"", 1, token.EOF, "", 7, ) + + // Starting identifier with ID_Continue char from Nm + test("\u0300", + token.ILLEGAL, + ) + + // Starting identifier with Pattern_Syntax + test("'", + token.ILLEGAL, + ) }) }