aboutsummaryrefslogtreecommitdiff
path: root/test/mocha
diff options
context:
space:
mode:
authorAnthony Van de Gejuchte <anthonyvdgent@gmail.com>2016-06-07 01:33:13 +0200
committerRichard van Velzen <rvanvelzen@experty.com>2016-06-08 19:45:21 +0200
commit8287ef67810f2332459fa157b26e556f55b36b98 (patch)
tree1cc5ba4b10a9640971d36b3dc67091510ca9d15d /test/mocha
parent5cb5305cf3a4dc075461630d5edd81cbfd04b9fc (diff)
downloadtracifyjs-8287ef67810f2332459fa157b26e556f55b36b98.tar.gz
tracifyjs-8287ef67810f2332459fa157b26e556f55b36b98.zip
Fix uglify attempting to rewrite invalid new expressions
Diffstat (limited to 'test/mocha')
-rw-r--r--test/mocha/new.js34
1 files changed, 34 insertions, 0 deletions
diff --git a/test/mocha/new.js b/test/mocha/new.js
new file mode 100644
index 00000000..7e7aea7d
--- /dev/null
+++ b/test/mocha/new.js
@@ -0,0 +1,34 @@
+var assert = require("assert");
+var uglify = require("../../");
+
+describe("New", function() {
+ it("Should attach callback parens after some tokens", function() {
+ var tests = [
+ "new x(1);",
+ "new (function(foo){this.foo=foo;})(1);",
+ "new true;",
+ "new (0);",
+ "new (!0);",
+ "new (bar = function(foo) {this.foo=foo;})(123);"
+ ];
+ var expected = [
+ "new x(1);",
+ "new function(foo) {\n this.foo = foo;\n}(1);",
+ "new true;",
+ "new 0;",
+ "new (!0);",
+ "new (bar = function(foo) {\n this.foo = foo;\n})(123);"
+ ];
+ for (var i = 0; i < tests.length; i++) {
+ assert.strictEqual(
+ uglify.minify(tests[i], {
+ fromString: true,
+ output: {beautify: true},
+ compress: false,
+ mangle: false
+ }).code,
+ expected[i]
+ );
+ }
+ });
+}); \ No newline at end of file