aboutsummaryrefslogtreecommitdiff
path: root/test/compress/evaluate.js
diff options
context:
space:
mode:
authorAlex Lam S.L <alexlamsl@gmail.com>2018-03-16 06:12:59 +0800
committerGitHub <noreply@github.com>2018-03-16 06:12:59 +0800
commit20ca0f5906c68df11d2f44e8b381212672afc6e1 (patch)
tree2a2fd0feb19255c26d3cd8167776804d10beb04c /test/compress/evaluate.js
parentb29d435bb5bc4d883a23efaabd76e95092352b6c (diff)
downloadtracifyjs-20ca0f5906c68df11d2f44e8b381212672afc6e1.tar.gz
tracifyjs-20ca0f5906c68df11d2f44e8b381212672afc6e1.zip
improve truthy compression (#3009)
Diffstat (limited to 'test/compress/evaluate.js')
-rw-r--r--test/compress/evaluate.js42
1 files changed, 41 insertions, 1 deletions
diff --git a/test/compress/evaluate.js b/test/compress/evaluate.js
index 0547e6d9..9d35ffa3 100644
--- a/test/compress/evaluate.js
+++ b/test/compress/evaluate.js
@@ -745,7 +745,7 @@ in_boolean_context: {
!b("foo"),
!b([1, 2]),
!b(/foo/),
- ![1, foo()],
+ (foo(), !1),
(foo(), !1)
);
}
@@ -1566,3 +1566,43 @@ issue_2968: {
}
expect_stdout: "PASS"
}
+
+truthy_conditionals: {
+ options = {
+ conditionals: true,
+ evaluate: true,
+ }
+ input: {
+ if (a = {}) x();
+ (b = /foo/) && y();
+ (c = function() {}) || z();
+ }
+ expect: {
+ a = {}, x();
+ b = /foo/, y();
+ c = function() {};
+ }
+}
+
+truthy_loops: {
+ options = {
+ evaluate: true,
+ loops: true,
+ }
+ input: {
+ while ([]) x();
+ do {
+ y();
+ } while(a = {});
+ }
+ expect: {
+ for (;;) {
+ [];
+ x();
+ }
+ for (;;) {
+ y();
+ a = {};
+ }
+ }
+}