aboutsummaryrefslogtreecommitdiff
path: root/test/compress/issue-597.js
blob: c988e9c116946b8bc2a0053cb675c2d01b12000f (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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
NaN_and_Infinity_must_have_parens: {
    options = {}
    input: {
        Infinity.toString();
        NaN.toString();
    }
    expect: {
        (1/0).toString();
        NaN.toString();
    }
}

NaN_and_Infinity_should_not_be_replaced_when_they_are_redefined: {
    options = {}
    input: {
        var Infinity, NaN;
        Infinity.toString();
        NaN.toString();
    }
    expect: {
        var Infinity, NaN;
        Infinity.toString();
        NaN.toString();
    }
}

NaN_and_Infinity_must_have_parens_evaluate: {
    options = {
        evaluate: true,
    }
    input: {
        (123456789 / 0).toString();
        (+"foo").toString();
    }
    expect: {
        (1/0).toString();
        NaN.toString();
    }
}

NaN_and_Infinity_should_not_be_replaced_when_they_are_redefined_evaluate: {
    options = {
        evaluate: true,
    }
    input: {
        var Infinity, NaN;
        (123456789 / 0).toString();
        (+"foo").toString();
    }
    expect: {
        var Infinity, NaN;
        (1/0).toString();
        (0/0).toString();
    }
}

beautify_off_1: {
    options = {
        evaluate: true,
    }
    beautify = {
        beautify: false,
    }
    input: {
        var NaN;
        console.log(
            null,
            undefined,
            Infinity,
            NaN,
            Infinity * undefined,
            Infinity.toString(),
            NaN.toString(),
            (Infinity * undefined).toString()
        );
    }
    expect_exact: "var NaN;console.log(null,void 0,1/0,NaN,0/0,(1/0).toString(),NaN.toString(),(0/0).toString());"
    expect_stdout: true
}

beautify_off_2: {
    options = {
        evaluate: true,
    }
    beautify = {
        beautify: false,
    }
    input: {
        console.log(
            null.toString(),
            undefined.toString()
        );
    }
    expect_exact: "console.log(null.toString(),(void 0).toString());"
}

beautify_on_1: {
    options = {
        evaluate: true,
    }
    beautify = {
        beautify: true,
    }
    input: {
        var NaN;
        console.log(
            null,
            undefined,
            Infinity,
            NaN,
            Infinity * undefined,
            Infinity.toString(),
            NaN.toString(),
            (Infinity * undefined).toString()
        );
    }
    expect_exact: [
        "var NaN;",
        "",
        "console.log(null, void 0, 1 / 0, NaN, 0 / 0, (1 / 0).toString(), NaN.toString(), (0 / 0).toString());",
    ]
    expect_stdout: true
}

beautify_on_2: {
    options = {
        evaluate: true,
    }
    beautify = {
        beautify: true,
    }
    input: {
        console.log(
            null.toString(),
            undefined.toString()
        );
    }
    expect_exact: "console.log(null.toString(), (void 0).toString());"
}

issue_1724: {
    input: {
        var a = 0;
        ++a % Infinity | Infinity ? a++ : 0;
        console.log(a);
    }
    expect_exact: "var a=0;++a%(1/0)|1/0?a++:0;console.log(a);"
    expect_stdout: "2"
}

issue_1725: {
    input: {
        ([].length === 0) % Infinity ? console.log("PASS") : console.log("FAIL");
    }
    expect_exact: '(0===[].length)%(1/0)?console.log("PASS"):console.log("FAIL");'
    expect_stdout: "PASS"
}