From a62b086184e70072929a218d97dd11ce8efdfaff Mon Sep 17 00:00:00 2001 From: "Alex Lam S.L" Date: Tue, 15 Sep 2020 15:59:10 +0100 Subject: enhance `merge_vars` (#4105) --- test/compress/merge_vars.js | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) (limited to 'test') diff --git a/test/compress/merge_vars.js b/test/compress/merge_vars.js index 6923fe73..4c5f6dac 100644 --- a/test/compress/merge_vars.js +++ b/test/compress/merge_vars.js @@ -76,6 +76,43 @@ merge_toplevel: { ] } +segment: { + options = { + merge_vars: true, + toplevel: true, + } + input: { + var a = "foo"; + console.log(a); + for (var c, i = 0; i < 1; i++) { + var b = "bar"; + console.log(b); + c = "baz"; + console.log(c); + } + var d = "moo"; + console.log(d); + } + expect: { + var d = "foo"; + console.log(d); + for (var c, i = 0; i < 1; i++) { + var c = "bar"; + console.log(c); + c = "baz"; + console.log(c); + } + var d = "moo"; + console.log(d); + } + expect_stdout: [ + "foo", + "bar", + "baz", + "moo", + ] +} + init_scope_vars: { options = { merge_vars: true, -- cgit v1.2.3