aboutsummaryrefslogtreecommitdiff
path: root/test/compress
diff options
context:
space:
mode:
Diffstat (limited to 'test/compress')
-rw-r--r--test/compress/issue-782.js28
-rw-r--r--test/compress/issue-973.js85
2 files changed, 99 insertions, 14 deletions
diff --git a/test/compress/issue-782.js b/test/compress/issue-782.js
index 2f72d1ab..6e1c92f5 100644
--- a/test/compress/issue-782.js
+++ b/test/compress/issue-782.js
@@ -1,11 +1,31 @@
+remove_sequence: {
+ options = {
+ side_effects: true,
+ }
+ input: {
+ (0, 1, eval)();
+ (0, 1, logThis)();
+ (0, 1, _decorators.logThis)();
+ }
+ expect: {
+ eval();
+ logThis();
+ (0, _decorators.logThis)();
+ }
+}
+
remove_redundant_sequence_items: {
- options = { side_effects: true };
+ options = {
+ side_effects: true,
+ }
input: {
+ "use strict";
(0, 1, eval)();
(0, 1, logThis)();
(0, 1, _decorators.logThis)();
}
expect: {
+ "use strict";
(0, eval)();
logThis();
(0, _decorators.logThis)();
@@ -13,13 +33,17 @@ remove_redundant_sequence_items: {
}
dont_remove_this_binding_sequence: {
- options = { side_effects: true };
+ options = {
+ side_effects: true,
+ }
input: {
+ "use strict";
(0, eval)();
(0, logThis)();
(0, _decorators.logThis)();
}
expect: {
+ "use strict";
(0, eval)();
logThis();
(0, _decorators.logThis)();
diff --git a/test/compress/issue-973.js b/test/compress/issue-973.js
index a9fcd84f..3eb25fac 100644
--- a/test/compress/issue-973.js
+++ b/test/compress/issue-973.js
@@ -3,8 +3,9 @@ this_binding_conditionals: {
conditionals: true,
evaluate: true,
side_effects: true,
- };
+ }
input: {
+ "use strict";
(1 && a)();
(0 || a)();
(0 || 1 && a)();
@@ -26,6 +27,7 @@ this_binding_conditionals: {
(1 ? eval : 0)();
}
expect: {
+ "use strict";
a();
a();
a();
@@ -53,13 +55,15 @@ this_binding_collapse_vars: {
collapse_vars: true,
toplevel: true,
unused: true,
- };
+ }
input: {
+ "use strict";
var c = a; c();
var d = a.b; d();
var e = eval; e();
}
expect: {
+ "use strict";
a();
(0, a.b)();
(0, eval)();
@@ -69,31 +73,88 @@ this_binding_collapse_vars: {
this_binding_side_effects: {
options = {
side_effects : true
- };
+ }
input: {
- (function (foo) {
+ (function(foo) {
+ (0, foo)();
+ (0, foo.bar)();
+ (0, eval)("console.log(foo);");
+ }());
+ (function(foo) {
+ "use strict";
(0, foo)();
(0, foo.bar)();
- (0, eval)('console.log(foo);');
+ (0, eval)("console.log(foo);");
}());
- (function (foo) {
+ (function(foo) {
var eval = console;
(0, foo)();
(0, foo.bar)();
- (0, eval)('console.log(foo);');
+ (0, eval)("console.log(foo);");
}());
}
expect: {
- (function (foo) {
+ (function(foo) {
foo();
(0, foo.bar)();
- (0, eval)('console.log(foo);');
+ eval("console.log(foo);");
}());
- (function (foo) {
+ (function(foo) {
+ "use strict";
+ foo();
+ (0, foo.bar)();
+ (0, eval)("console.log(foo);");
+ }());
+ (function(foo) {
var eval = console;
foo();
(0, foo.bar)();
- (0, eval)('console.log(foo);');
+ eval("console.log(foo);");
+ }());
+ }
+}
+
+this_binding_sequences: {
+ options = {
+ sequences: true,
+ side_effects: true,
+ }
+ input: {
+ console.log(typeof function() {
+ return eval("this");
+ }());
+ console.log(typeof function() {
+ "use strict";
+ return eval("this");
+ }());
+ console.log(typeof function() {
+ return (0, eval)("this");
+ }());
+ console.log(typeof function() {
+ "use strict";
+ return (0, eval)("this");
+ }());
+ }
+ expect: {
+ console.log(typeof function() {
+ return eval("this");
+ }()),
+ console.log(typeof function() {
+ "use strict";
+ return eval("this");
+ }()),
+ console.log(typeof function() {
+ return eval("this");
+ }()),
+ console.log(typeof function() {
+ "use strict";
+ return (0, eval)("this");
}());
}
-} \ No newline at end of file
+ expect_stdout: [
+ "object",
+ "undefined",
+ "object",
+ "object",
+ ]
+}