UglifyJS/test/compress/issue-973.js

97 lines
1.8 KiB
JavaScript
Raw Normal View History

this_binding_conditionals: {
options = {
conditionals: true,
evaluate : true
};
input: {
(1 && a)();
(0 || a)();
(0 || 1 && a)();
(1 ? a : 0)();
(1 && a.b)();
(0 || a.b)();
(0 || 1 && a.b)();
(1 ? a.b : 0)();
(1 && a[b])();
(0 || a[b])();
(0 || 1 && a[b])();
(1 ? a[b] : 0)();
2016-02-16 18:52:28 +00:00
(1 && eval)();
(0 || eval)();
(0 || 1 && eval)();
(1 ? eval : 0)();
}
expect: {
a();
a();
a();
a();
(0, a.b)();
(0, a.b)();
(0, a.b)();
(0, a.b)();
(0, a[b])();
(0, a[b])();
(0, a[b])();
(0, a[b])();
2016-02-16 18:52:28 +00:00
(0, eval)();
(0, eval)();
(0, eval)();
(0, eval)();
}
}
this_binding_collapse_vars: {
options = {
collapse_vars: true,
toplevel: true,
};
input: {
var c = a; c();
var d = a.b; d();
2016-02-16 18:52:28 +00:00
var e = eval; e();
}
expect: {
a();
(0, a.b)();
2016-02-16 18:52:28 +00:00
(0, eval)();
}
2016-02-16 18:00:48 +00:00
}
2016-02-16 18:52:28 +00:00
this_binding_side_effects: {
2016-02-16 18:00:48 +00:00
options = {
2016-02-16 18:52:28 +00:00
side_effects : true
};
2016-02-16 18:00:48 +00:00
input: {
2016-02-16 18:52:28 +00:00
(function (foo) {
(0, foo)();
(0, foo.bar)();
(0, eval)('console.log(foo);');
}());
(function (foo) {
var eval = console;
(0, foo)();
(0, foo.bar)();
(0, eval)('console.log(foo);');
}());
2016-02-16 18:00:48 +00:00
}
expect: {
2016-02-16 18:52:28 +00:00
(function (foo) {
foo();
(0, foo.bar)();
(0, eval)('console.log(foo);');
}());
(function (foo) {
var eval = console;
foo();
(0, foo.bar)();
(0, eval)('console.log(foo);');
}());
2016-02-16 18:00:48 +00:00
}
}