Skip to content

Commit 2bdfe08

Browse files
committed
test(lexer): add test for invalid escape sequence handling
1 parent 1a358e1 commit 2bdfe08

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

tests/lexer/lexer.test.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
/* eslint-disable max-nested-callbacks */
2+
13
/* Imports */
24
import { Lexer } from "../../src/lexer/lexer.js";
35
import { Token, TokenEnum } from "../../src/lexer/token";
@@ -178,6 +180,11 @@ describe("Lexer", () => {
178180
new Token(TokenEnum.STRING, "hello\rworld"),
179181
]);
180182
});
183+
184+
it("should error on invalid escape sequence", () => {
185+
const lexer = new Lexer('"hello\\xworld"');
186+
expect(() => lexer.lex()).toThrow("Invalid escape sequence: \\x");
187+
});
181188
});
182189

183190
describe("should handle numeric escape sequences", () => {

0 commit comments

Comments
 (0)