From 4219ee276ad0c7c05a843d1a6c458424a2a8cb17 Mon Sep 17 00:00:00 2001 From: Jay Bazuzi Date: Thu, 7 Aug 2025 18:45:10 -0700 Subject: [PATCH] . t tests for name scoping conflicts --- .../rename/nested-scope-conflict-1.input.ts | 16 ++++++++++++++++ .../rename/nested-scope-conflict-2.input.ts | 16 ++++++++++++++++ 2 files changed, 32 insertions(+) create mode 100644 tests/fixtures/commands/rename/nested-scope-conflict-1.input.ts create mode 100644 tests/fixtures/commands/rename/nested-scope-conflict-2.input.ts diff --git a/tests/fixtures/commands/rename/nested-scope-conflict-1.input.ts b/tests/fixtures/commands/rename/nested-scope-conflict-1.input.ts new file mode 100644 index 0000000..68f0214 --- /dev/null +++ b/tests/fixtures/commands/rename/nested-scope-conflict-1.input.ts @@ -0,0 +1,16 @@ +/** + * @description Renaming x to y should cause a name conflict with inner y + * @command refakts rename "[nested-scope-conflict-1.input.ts 7:9-7:10]" --to "y" + */ + +function f() { + const x = 1; + { + const y = 2; + { + return x; + } + } +} + +expect(f()).toBe(1); diff --git a/tests/fixtures/commands/rename/nested-scope-conflict-2.input.ts b/tests/fixtures/commands/rename/nested-scope-conflict-2.input.ts new file mode 100644 index 0000000..c9a7010 --- /dev/null +++ b/tests/fixtures/commands/rename/nested-scope-conflict-2.input.ts @@ -0,0 +1,16 @@ +/** + * @description Renaming y to x should cause a name conflict with outer x + * @command refakts rename "[nested-scope-conflict-2.input.ts 9:9-9:10]" --to "x" + */ + +function f() { + const x = 1; + { + const y = 2; + { + return x; + } + } +} + +expect(f()).toBe(1);