[Pkg-javascript-commits] [uglifyjs] 37/49: Pass mangle options to figure_out_scope before mangling in tests

Jonas Smedegaard dr at jones.dk
Fri Dec 9 11:43:32 UTC 2016


This is an automated email from the git hooks/post-receive script.

js pushed a commit to branch master
in repository uglifyjs.

commit 057de570e69b300ca472719cb234a32e593d34ec
Author: Anthony Van de Gejuchte <anthonyvdgent at gmail.com>
Date:   Wed Oct 26 12:34:38 2016 +0200

    Pass mangle options to figure_out_scope before mangling in tests
---
 test/compress/screw-ie8.js | 114 ++++++++++++++++++++++++++++++++++++++++++++-
 test/mocha/screw-ie8.js    |  23 +++++++++
 test/run-tests.js          |   2 +-
 3 files changed, 137 insertions(+), 2 deletions(-)

diff --git a/test/compress/screw-ie8.js b/test/compress/screw-ie8.js
index 527aea0..0a4e232 100644
--- a/test/compress/screw-ie8.js
+++ b/test/compress/screw-ie8.js
@@ -15,4 +15,116 @@ dont_screw: {
 
     input: f("\v");
     expect_exact: 'f("\\x0B");';
-}
\ No newline at end of file
+}
+
+do_screw_try_catch: {
+    options = { screw_ie8: true };
+    mangle = { screw_ie8: true };
+    beautify = { screw_ie8: true };
+    input: {
+        good = function(e){
+            return function(error){
+                try{
+                    e()
+                } catch(e) {
+                    error(e)
+                }
+            }
+        };
+    }
+    expect: {
+        good = function(n){
+            return function(t){
+                try{
+                    n()
+                } catch(n) {
+                    t(n)
+                }
+            }
+        };
+    }
+}
+
+dont_screw_try_catch: {
+    options = { screw_ie8: false };
+    mangle = { screw_ie8: false };
+    beautify = { screw_ie8: false };
+    input: {
+        bad = function(e){
+            return function(error){
+                try{
+                    e()
+                } catch(e) {
+                    error(e)
+                }
+            }
+        };
+    }
+    expect: {
+        bad = function(n){
+            return function(n){
+                try{
+                    t()
+                } catch(t) {
+                    n(t)
+                }
+            }
+        };
+    }
+}
+
+do_screw_try_catch_undefined: {
+    options = { screw_ie8: true };
+    mangle = { screw_ie8: true };
+    beautify = { screw_ie8: true };
+    input: {
+        function a(b){
+            try {
+                throw 'Stuff';
+            } catch (undefined) {
+                console.log('caught: ' + undefined);
+            }
+            console.log('undefined is ' + undefined);
+            return b === undefined;
+        };
+    }
+    expect: {
+        function a(o){
+            try{
+                throw "Stuff"
+            } catch (o) {
+                console.log("caught: "+o)
+            }
+            console.log("undefined is " + void 0);
+            return void 0===o
+        }
+    }
+}
+
+dont_screw_try_catch_undefined: {
+    options = { screw_ie8: false };
+    mangle = { screw_ie8: false };
+    beautify = { screw_ie8: false };
+    input: {
+        function a(b){
+            try {
+                throw 'Stuff';
+            } catch (undefined) {
+                console.log('caught: ' + undefined);
+            }
+            console.log('undefined is ' + undefined);
+            return b === undefined;
+        };
+    }
+    expect: {
+        function a(o){
+            try{
+                throw "Stuff"
+            } catch (n) {
+                console.log("caught: "+n)
+            }
+            console.log("undefined is " + void 0);
+            return void 0===o
+        }
+    }
+}
diff --git a/test/mocha/screw-ie8.js b/test/mocha/screw-ie8.js
new file mode 100644
index 0000000..28b092e
--- /dev/null
+++ b/test/mocha/screw-ie8.js
@@ -0,0 +1,23 @@
+var assert = require("assert");
+var uglify = require("../../");
+
+describe("screw-ie8", function () {
+    it("Should be able to minify() with undefined as catch parameter in a try...catch statement", function () {
+        assert.strictEqual(
+            uglify.minify(
+                "function a(b){\
+                    try {\
+                        throw 'Stuff';\
+                    } catch (undefined) {\
+                        console.log('caught: ' + undefined);\
+                    }\
+                    console.log('undefined is ' + undefined);\
+                    return b === undefined;\
+                };", {
+                    fromString: true
+                }
+            ).code,
+            'function a(o){try{throw"Stuff"}catch(o){console.log("caught: "+o)}return console.log("undefined is "+void 0),void 0===o}'
+        );
+    });
+});
diff --git a/test/run-tests.js b/test/run-tests.js
index 4063870..8fb93c8 100755
--- a/test/run-tests.js
+++ b/test/run-tests.js
@@ -117,7 +117,7 @@ function run_compress_tests() {
                 input = U.mangle_properties(input, test.mangle_props);
             }
             var output = cmp.compress(input);
-            output.figure_out_scope();
+            output.figure_out_scope(test.mangle);
             if (test.mangle) {
                 output.compute_char_frequency(test.mangle);
                 output.mangle_names(test.mangle);

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/uglifyjs.git



More information about the Pkg-javascript-commits mailing list