aboutsummaryrefslogtreecommitdiff
path: root/test/compress
diff options
context:
space:
mode:
authoralexlamsl <alexlamsl@gmail.com>2016-02-16 18:15:59 +0800
committerRichard van Velzen <rvanvelzen@experty.com>2016-02-16 18:47:49 +0100
commit31a9b05c9642d8b402611d49ea23a6c2902cf374 (patch)
tree4f7e9d5a4ede4a42d56de4f577ee132693c74207 /test/compress
parent63b01fe8f9ed9f340884ce3dc1555c2024d81e23 (diff)
downloadtracifyjs-31a9b05c9642d8b402611d49ea23a6c2902cf374.tar.gz
tracifyjs-31a9b05c9642d8b402611d49ea23a6c2902cf374.zip
Preserve ThisBinding in conditionals & collapse_vars
Fixes #973
Diffstat (limited to 'test/compress')
-rw-r--r--test/compress/issue-782.js6
-rw-r--r--test/compress/issue-973.js52
2 files changed, 55 insertions, 3 deletions
diff --git a/test/compress/issue-782.js b/test/compress/issue-782.js
index cce15fd1..80b1493c 100644
--- a/test/compress/issue-782.js
+++ b/test/compress/issue-782.js
@@ -5,19 +5,19 @@ remove_redundant_sequence_items: {
(0, 1, _decorators.logThis)();
}
expect: {
- (0, logThis)();
+ logThis();
(0, _decorators.logThis)();
}
}
-dont_remove_lexical_binding_sequence: {
+dont_remove_this_binding_sequence: {
options = { side_effects: true };
input: {
(0, logThis)();
(0, _decorators.logThis)();
}
expect: {
- (0, logThis)();
+ logThis();
(0, _decorators.logThis)();
}
}
diff --git a/test/compress/issue-973.js b/test/compress/issue-973.js
new file mode 100644
index 00000000..41fb0e25
--- /dev/null
+++ b/test/compress/issue-973.js
@@ -0,0 +1,52 @@
+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)();
+ }
+ 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])();
+ }
+}
+
+this_binding_collapse_vars: {
+ options = {
+ collapse_vars: true,
+ };
+ input: {
+ var c = a; c();
+ var d = a.b; d();
+ }
+ expect: {
+ a();
+ (0, a.b)();
+ }
+} \ No newline at end of file