aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/compress/new.js8
-rw-r--r--test/mocha/new.js34
2 files changed, 42 insertions, 0 deletions
diff --git a/test/compress/new.js b/test/compress/new.js
index 4b2c51c3..d956ae27 100644
--- a/test/compress/new.js
+++ b/test/compress/new.js
@@ -10,3 +10,11 @@ new_statement: {
}
expect_exact: "new x(1);new x(1)(2);new x(1)(2)(3);new new x(1);new new x(1)(2);new new x(1)(2);(new new x(1))(2);"
}
+
+new_with_rewritten_true_value: {
+ options = { booleans: true }
+ input: {
+ new true;
+ }
+ expect_exact: "new(!0);"
+}
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