From 542efcd0df2a0102dff5c1505d934950a60faa9d Mon Sep 17 00:00:00 2001 From: Ruben Verborgh Date: Fri, 8 Sep 2017 20:04:28 -0400 Subject: [PATCH] Add test for multiple var statements. Tests #685. --- .../__tests__/dead-code-elimination-test.js | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/packages/babel-plugin-minify-dead-code-elimination/__tests__/dead-code-elimination-test.js b/packages/babel-plugin-minify-dead-code-elimination/__tests__/dead-code-elimination-test.js index 045305e7d..99b8f3e32 100644 --- a/packages/babel-plugin-minify-dead-code-elimination/__tests__/dead-code-elimination-test.js +++ b/packages/babel-plugin-minify-dead-code-elimination/__tests__/dead-code-elimination-test.js @@ -405,6 +405,28 @@ describe("dce-plugin", () => { ` ); + thePlugin( + "should not inline vars modified in different var statements - issue #685", + ` + function f() { + var a = 1; + var b = a; + var a = 2; + console.log(a, b); + } + f(); + `, + ` + function f() { + var a = 1; + var b = a; + var a = 2; + console.log(a, b); + } + f(); + ` + ); + thePlugin( "should remove redundant returns", `