diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/compress/conditionals.js | 73 | ||||
-rw-r--r-- | test/compress/evaluate.js | 67 |
2 files changed, 136 insertions, 4 deletions
diff --git a/test/compress/conditionals.js b/test/compress/conditionals.js index 22947d86..89c05263 100644 --- a/test/compress/conditionals.js +++ b/test/compress/conditionals.js @@ -1016,7 +1016,7 @@ delete_conditional_2: { expect_stdout: true } -issue_2535: { +issue_2535_1: { options = { booleans: true, conditionals: true, @@ -1044,3 +1044,74 @@ issue_2535: { (x(), 0) && y(); } } + +issue_2535_2: { + options = { + booleans: true, + conditionals: true, + evaluate: true, + side_effects: true, + } + input: { + function x() {} + function y() { + return "foo"; + } + console.log((x() || true) || y()); + console.log((y() || true) || x()); + console.log((x() || true) && y()); + console.log((y() || true) && x()); + console.log((x() && true) || y()); + console.log((y() && true) || x()); + console.log((x() && true) && y()); + console.log((y() && true) && x()); + console.log((x() || false) || y()); + console.log((y() || false) || x()); + console.log((x() || false) && y()); + console.log((y() || false) && x()); + console.log((x() && false) || y()); + console.log((y() && false) || x()); + console.log((x() && false) && y()); + console.log((y() && false) && x()); + } + expect: { + function x() {} + function y() { + return "foo"; + } + console.log(x() || !0); + console.log(y() || !0); + console.log((x(), y())); + console.log((y(), x())); + console.log(!!x() || y()); + console.log(!!y() || x()); + console.log(x() && y()); + console.log(y() && x()); + console.log(x() || y()); + console.log(y() || x()); + console.log(!!x() && y()); + console.log(!!y() && x()); + console.log((x(), y())); + console.log((y(), x())); + console.log(x() && !1); + console.log(y() && !1); + } + expect_stdout: [ + "true", + "foo", + "foo", + "undefined", + "foo", + "true", + "undefined", + "undefined", + "foo", + "foo", + "false", + "undefined", + "foo", + "undefined", + "undefined", + "false", + ] +} diff --git a/test/compress/evaluate.js b/test/compress/evaluate.js index 04b15a8c..8e030d22 100644 --- a/test/compress/evaluate.js +++ b/test/compress/evaluate.js @@ -1,6 +1,7 @@ and: { options = { - evaluate: true + evaluate: true, + side_effects: true, } input: { var a; @@ -76,7 +77,8 @@ and: { or: { options = { - evaluate: true + evaluate: true, + side_effects: true, } input: { var a; @@ -158,7 +160,8 @@ or: { unary_prefix: { options = { - evaluate: true + evaluate: true, + side_effects: true, } input: { a = !0 && b; @@ -1245,3 +1248,61 @@ self_comparison_2: { } expect_stdout: "false false true true 'number'" } + +issue_2535_1: { + options = { + booleans: true, + evaluate: true, + sequences: true, + side_effects: true, + } + input: { + if ((x() || true) || y()) z(); + if ((x() || true) && y()) z(); + if ((x() && true) || y()) z(); + if ((x() && true) && y()) z(); + if ((x() || false) || y()) z(); + if ((x() || false) && y()) z(); + if ((x() && false) || y()) z(); + if ((x() && false) && y()) z(); + } + expect: { + if (x(), 1) z(); + if (x(), y()) z(); + if (x() || y()) z(); + if (x() && y()) z(); + if (x() || y()) z(); + if (x() && y()) z(); + if (x(), y()) z(); + if (x(), 0) z(); + } +} + +issue_2535_2: { + options = { + booleans: true, + evaluate: true, + sequences: true, + side_effects: true, + } + input: { + (x() || true) || y(); + (x() || true) && y(); + (x() && true) || y(); + (x() && true) && y(); + (x() || false) || y(); + (x() || false) && y(); + (x() && false) || y(); + (x() && false) && y(); + } + expect: { + x(), + x(), y(), + x() || y(), + x() && y(), + x() || y(), + x() && y(), + x(), y(), + x(); + } +} |