aboutsummaryrefslogtreecommitdiff
path: root/test/compress/issue-3768.js
blob: c467fa6494b3bcf9a33da8d0b2db5e87ffe8d25d (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
mangle: {
    mangle = {
        toplevel: true,
    }
    input: {
        var e = eval, x = 42;
        (function() {
            console.log(e("typeof x"));
        })();
    }
    expect: {
        var e = eval, x = 42;
        (function() {
            console.log(e("typeof x"));
        })();
    }
    expect_stdout: true
}

compress: {
    options = {
        collapse_vars: true,
        inline: true,
        unused: true,
    }
    input: {
        console.log(function() {
            var a = 42;
            return eval("typeof a");
        }(), function(e) {
            var a = null;
            return e("typeof a");
        }(eval), function(eval) {
            var a = false;
            return eval("typeof a");
        }(eval), function(f) {
            var a = "STRING";
            var eval = f;
            return eval("typeof a");
        }(eval), function(g) {
            var a = eval;
            function eval() {
                return g;
            }
            return eval()("typeof a");
        }(eval));
    }
    expect: {
        console.log(function() {
            var a = 42;
            return eval("typeof a");
        }(), (0, eval)("typeof a"), function(eval) {
            var a = false;
            return eval("typeof a");
        }(eval), function(f) {
            var a = "STRING";
            var eval = f;
            return eval("typeof a");
        }(eval), function(g) {
            var a = eval;
            function eval() {
                return g;
            }
            return eval()("typeof a");
        }(eval));
    }
    expect_stdout: "number undefined boolean string undefined"
}

call_arg_1: {
    mangle = {
        toplevel: true,
    }
    input: {
        var z = "foo";
        (function() {
            var z = false;
            (function(e) {
                var z = 42;
                e("console.log(typeof z)");
            })(eval);
        })();
    }
    expect: {
        var z = "foo";
        (function() {
            var o = false;
            (function(o) {
                var a = 42;
                o("console.log(typeof z)");
            })(eval);
        })();
    }
    expect_stdout: true
}

call_arg_2: {
    mangle = {
        toplevel: true,
    }
    input: {
        function eval() {
            console.log("PASS");
        }
        var z = "foo";
        (function() {
            var z = false;
            (function(e) {
                var z = 42;
                e("console.log(typeof z)");
            })(eval);
        })();
    }
    expect: {
        function n() {
            console.log("PASS");
        }
        var o = "foo";
        (function() {
            var o = false;
            (function(o) {
                var n = 42;
                o("console.log(typeof z)");
            })(n);
        })();
    }
    expect_stdout: "PASS"
}