aboutsummaryrefslogtreecommitdiff
path: root/test/compress
diff options
context:
space:
mode:
authorAlex Lam S.L <alexlamsl@gmail.com>2018-05-10 06:16:35 +0800
committerGitHub <noreply@github.com>2018-05-10 06:16:35 +0800
commit14e712ee802da2a6199653268f8519187ece2c51 (patch)
tree0a0381a2de77ccc31bac130441ad6233da84d868 /test/compress
parentf83adcc9958ad0fc98c175a4d19ad3d37d228f24 (diff)
downloadtracifyjs-14e712ee802da2a6199653268f8519187ece2c51.tar.gz
tracifyjs-14e712ee802da2a6199653268f8519187ece2c51.zip
fix corner case in call binding (#3128)
fixes #3127
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",
+ ]
+}