From 2cb55b2ad0119852bc8714401992724d4fdb224d Mon Sep 17 00:00:00 2001 From: "Alex Lam S.L" Date: Sun, 30 Apr 2017 22:52:36 +0800 Subject: enforce `toplevel` on other compress options (#1855) Respect "funcs" and "vars" properly. fixes #1850 --- test/compress/reduce_vars.js | 90 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 90 insertions(+) (limited to 'test/compress/reduce_vars.js') diff --git a/test/compress/reduce_vars.js b/test/compress/reduce_vars.js index 57e23891..f7bdcb36 100644 --- a/test/compress/reduce_vars.js +++ b/test/compress/reduce_vars.js @@ -2327,3 +2327,93 @@ iife_assign: { } expect_stdout: "1" } + +issue_1850_1: { + options = { + reduce_vars: true, + toplevel: false, + unused: true, + } + input: { + function f() { + console.log(a, a, a); + } + var a = 1; + f(); + } + expect: { + function f() { + console.log(a, a, a); + } + var a = 1; + f(); + } + expect_stdout: true +} + +issue_1850_2: { + options = { + reduce_vars: true, + toplevel: "funcs", + unused: true, + } + input: { + function f() { + console.log(a, a, a); + } + var a = 1; + f(); + } + expect: { + var a = 1; + (function() { + console.log(a, a, a); + })(); + } + expect_stdout: true +} + +issue_1850_3: { + options = { + reduce_vars: true, + toplevel: "vars", + unused: true, + } + input: { + function f() { + console.log(a, a, a); + } + var a = 1; + f(); + } + expect: { + function f() { + console.log(a, a, a); + } + var a = 1; + f(); + } + expect_stdout: true +} + +issue_1850_4: { + options = { + reduce_vars: true, + toplevel: true, + unused: true, + } + input: { + function f() { + console.log(a, a, a); + } + var a = 1; + f(); + } + expect: { + var a = 1; + (function() { + console.log(a, a, a); + })(); + } + expect_stdout: true +} -- cgit v1.2.3