From e31ab3a6c4229c0930dda53736544be9c6450621 Mon Sep 17 00:00:00 2001 From: Jesse Luoto Date: Sun, 6 Oct 2024 23:41:35 +0300 Subject: [PATCH] Add more invalid identifier tests --- .../visit-all-identifiers.test.ts | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/src/plugins/local-llm-rename/visit-all-identifiers.test.ts b/src/plugins/local-llm-rename/visit-all-identifiers.test.ts index a447e97..7c2fd33 100644 --- a/src/plugins/local-llm-rename/visit-all-identifiers.test.ts +++ b/src/plugins/local-llm-rename/visit-all-identifiers.test.ts @@ -213,3 +213,24 @@ test("should handle invalid identifiers", async () => { const result = await visitAllIdentifiers(code, async () => "this.kLength"); assert.equal(result, "const thisKLength = 1;"); }); + +test("should handle reserved identifiers", async () => { + const code = `const a = 1`; + const result = await visitAllIdentifiers(code, async () => "static"); + assert.equal(result, "const _static = 1;"); +}); + +test("should handle multiple identifiers named the same", async () => { + const code = ` +const a = 1; +const b = 1; +`.trim(); + const result = await visitAllIdentifiers(code, async () => "foo"); + assert.equal( + result, + ` +const foo = 1; +const _foo = 1; +`.trim() + ); +});