From 55ce14387efef4c958bfd3587b4deaf87970068a Mon Sep 17 00:00:00 2001 From: Florent Cailhol Date: Fri, 25 May 2018 15:37:15 +0200 Subject: [PATCH] Add test case --- test/cases/parsing/issue-7335/a.js | 1 + test/cases/parsing/issue-7335/index.js | 27 ++++++++++++++++++++++++++ 2 files changed, 28 insertions(+) create mode 100644 test/cases/parsing/issue-7335/a.js create mode 100644 test/cases/parsing/issue-7335/index.js diff --git a/test/cases/parsing/issue-7335/a.js b/test/cases/parsing/issue-7335/a.js new file mode 100644 index 00000000000..2cf44cad69a --- /dev/null +++ b/test/cases/parsing/issue-7335/a.js @@ -0,0 +1 @@ +export default 9; diff --git a/test/cases/parsing/issue-7335/index.js b/test/cases/parsing/issue-7335/index.js new file mode 100644 index 00000000000..93f603c860b --- /dev/null +++ b/test/cases/parsing/issue-7335/index.js @@ -0,0 +1,27 @@ +import x from "./a"; + +const sum1 = (x, y, total = x + y) => total; +const id1 = (a = x) => a; + +function sum2(x, y, total = x + y) { return total; } +function id2(a = x) { return a; } + +const sum3 = function(x, y, total = x + y) { return total; } +const id3 = function(a = x) { return a; } + +it("should shadow imported bindings", () => { + // Arrow functions + expect(sum1(2, 3)).toBe(5); + expect(id1(1)).toBe(1); + expect(id1()).toBe(9); + + // Function declarations + expect(sum2(2, 3)).toBe(5); + expect(id2(1)).toBe(1); + expect(id2()).toBe(9); + + // Function expressions + expect(sum3(2, 3)).toBe(5); + expect(id3(1)).toBe(1); + expect(id3()).toBe(9); +});