diff options
author | Alex Lam S.L <alexlamsl@gmail.com> | 2017-03-05 13:13:44 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-03-05 13:13:44 +0800 |
commit | b70591be1a603d3c1728e6563691c3a192023d3f (patch) | |
tree | c7b72062b2418b8423b04047cac152d40def7105 /test | |
parent | b33e7f88e60f886ee3403c82ac2e3fb40caa698f (diff) | |
download | tracifyjs-b70591be1a603d3c1728e6563691c3a192023d3f.tar.gz tracifyjs-b70591be1a603d3c1728e6563691c3a192023d3f.zip |
handle variable declaration within catch blocks (#1546)
accounts for IE8- scoping
Diffstat (limited to 'test')
-rw-r--r-- | test/compress/reduce_vars.js | 23 | ||||
-rw-r--r-- | test/compress/screw-ie8.js | 34 |
2 files changed, 57 insertions, 0 deletions
diff --git a/test/compress/reduce_vars.js b/test/compress/reduce_vars.js index 557631bd..70e915d3 100644 --- a/test/compress/reduce_vars.js +++ b/test/compress/reduce_vars.js @@ -605,6 +605,29 @@ inner_var_for_in_2: { } } +inner_var_catch: { + options = { + evaluate: true, + reduce_vars: true, + } + input: { + try { + a(); + } catch (e) { + var b = 1; + } + console.log(b); + } + expect: { + try { + a(); + } catch (e) { + var b = 1; + } + console.log(b); + } +} + issue_1533_1: { options = { collapse_vars: true, diff --git a/test/compress/screw-ie8.js b/test/compress/screw-ie8.js index 51379b15..36eb4d3a 100644 --- a/test/compress/screw-ie8.js +++ b/test/compress/screw-ie8.js @@ -148,3 +148,37 @@ dont_screw_try_catch_undefined: { } } } + +reduce_vars: { + options = { + evaluate: true, + reduce_vars: true, + screw_ie8: false, + unused: true, + } + mangle = { + screw_ie8: false, + } + input: { + function f() { + var a; + try { + x(); + } catch (a) { + y(); + } + alert(a); + } + } + expect: { + function f() { + var t; + try { + x(); + } catch (t) { + y(); + } + alert(t); + } + } +} |