aboutsummaryrefslogtreecommitdiff
path: root/test/compress
diff options
context:
space:
mode:
authorAlex Lam S.L <alexlamsl@gmail.com>2017-03-31 02:57:47 +0800
committerGitHub <noreply@github.com>2017-03-31 02:57:47 +0800
commitc595b84032b3083b87a976c8387010bf6074ad93 (patch)
tree7b4b6df422d94e852de672532d4ef9cb8acad8b6 /test/compress
parent7cb1adf455f8ab440e1971ae41265c1f7f9a806a (diff)
downloadtracifyjs-c595b84032b3083b87a976c8387010bf6074ad93.tar.gz
tracifyjs-c595b84032b3083b87a976c8387010bf6074ad93.zip
fix catch symbol mangling (#1734)
Only need to look up the immediate non-block/catch scope for the same-name special case. fixes #1733
Diffstat (limited to 'test/compress')
-rw-r--r--test/compress/issue-1733.js97
1 files changed, 97 insertions, 0 deletions
diff --git a/test/compress/issue-1733.js b/test/compress/issue-1733.js
new file mode 100644
index 00000000..3a940c96
--- /dev/null
+++ b/test/compress/issue-1733.js
@@ -0,0 +1,97 @@
+function_iife_catch: {
+ mangle = {
+ screw_ie8: true,
+ }
+ input: {
+ function f(n) {
+ !function() {
+ try {
+ throw 0;
+ } catch (n) {
+ var a = 1;
+ console.log(n, a);
+ }
+ }();
+ }
+ f();
+ }
+ expect_exact: "function f(o){!function(){try{throw 0}catch(c){var o=1;console.log(c,o)}}()}f();"
+ expect_stdout: "0 1"
+}
+
+function_iife_catch_ie8: {
+ mangle = {
+ screw_ie8: false,
+ }
+ input: {
+ function f(n) {
+ !function() {
+ try {
+ throw 0;
+ } catch (n) {
+ var a = 1;
+ console.log(n, a);
+ }
+ }();
+ }
+ f();
+ }
+ expect_exact: "function f(o){!function(){try{throw 0}catch(o){var c=1;console.log(o,c)}}()}f();"
+ expect_stdout: "0 1"
+}
+
+function_catch_catch: {
+ mangle = {
+ screw_ie8: true,
+ }
+ input: {
+ var o = 0;
+ function f() {
+ try {
+ throw 1;
+ } catch (c) {
+ try {
+ throw 2;
+ } catch (o) {
+ var o = 3;
+ console.log(o);
+ }
+ }
+ console.log(o);
+ }
+ f();
+ }
+ expect_exact: "var o=0;function f(){try{throw 1}catch(c){try{throw 2}catch(o){var o=3;console.log(o)}}console.log(o)}f();"
+ expect_stdout: [
+ "3",
+ "undefined",
+ ]
+}
+
+function_catch_catch_ie8: {
+ mangle = {
+ screw_ie8: false,
+ }
+ input: {
+ var o = 0;
+ function f() {
+ try {
+ throw 1;
+ } catch (c) {
+ try {
+ throw 2;
+ } catch (o) {
+ var o = 3;
+ console.log(o);
+ }
+ }
+ console.log(o);
+ }
+ f();
+ }
+ expect_exact: "var o=0;function f(){try{throw 1}catch(c){try{throw 2}catch(o){var o=3;console.log(o)}}console.log(o)}f();"
+ expect_stdout: [
+ "3",
+ "undefined",
+ ]
+}