aboutsummaryrefslogtreecommitdiff
path: root/test/compress/new.js
blob: 78a1026e76044fa70b76eb790150a654712f99db (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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
new_statement: {
    input: {
        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);
    }
    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_statements_2: {
    input: {
        new x;
        new new x;
        new new new x;
        new true;
        new (0);
        new (!0);
        new (bar = function(foo) {this.foo=foo;})(123);
        new (bar = function(foo) {this.foo=foo;})();
    }
    expect_exact: "new x;new(new x);new(new(new x));new true;new 0;new(!0);new(bar=function(foo){this.foo=foo})(123);new(bar=function(foo){this.foo=foo});"
}

new_statements_3: {
    input: {
        new (function(foo){this.foo=foo;})(1);
        new (function(foo){this.foo=foo;})();
        new (function test(foo){this.foo=foo;})(1);
        new (function test(foo){this.foo=foo;})();
    }
    expect_exact: "new function(foo){this.foo=foo}(1);new function(foo){this.foo=foo};new function test(foo){this.foo=foo}(1);new function test(foo){this.foo=foo};"
}

new_with_rewritten_true_value: {
    options = { booleans: true }
    input: {
        new true;
    }
    expect_exact: "new(!0);"
}

new_with_many_parameters: {
    input: {
        new foo.bar("baz");
        new x(/123/, 456);
    }
    expect_exact: 'new foo.bar("baz");new x(/123/,456);'
}