aboutsummaryrefslogtreecommitdiff
path: root/test/mocha/new.js
blob: 7e7aea7df11178a1e2afbe12825885005062cbe8 (about) (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
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]
            );
        }
    });
});