From ace8aaa0f4ad6ecae77e760473353f07b384880e Mon Sep 17 00:00:00 2001 From: kzc Date: Tue, 21 Jun 2016 14:52:13 -0400 Subject: Fix conditional expressions of form (x ? -1 : -1) Fixes #1154, #1153 --- test/compress/conditionals.js | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) (limited to 'test/compress') diff --git a/test/compress/conditionals.js b/test/compress/conditionals.js index f5eeb6f2..35cb26f7 100644 --- a/test/compress/conditionals.js +++ b/test/compress/conditionals.js @@ -868,3 +868,41 @@ trivial_boolean_ternary_expressions : { f(!(x >= y)); } } + +issue_1154: { + options = { + conditionals: true, + evaluate : true, + booleans : true, + }; + input: { + function f1(x) { return x ? -1 : -1; } + function f2(x) { return x ? +2 : +2; } + function f3(x) { return x ? ~3 : ~3; } + function f4(x) { return x ? !4 : !4; } + function f5(x) { return x ? void 5 : void 5; } + function f6(x) { return x ? typeof 6 : typeof 6; } + + function g1() { return g() ? -1 : -1; } + function g2() { return g() ? +2 : +2; } + function g3() { return g() ? ~3 : ~3; } + function g4() { return g() ? !4 : !4; } + function g5() { return g() ? void 5 : void 5; } + function g6() { return g() ? typeof 6 : typeof 6; } + } + expect: { + function f1(x) { return -1; } + function f2(x) { return 2; } + function f3(x) { return -4; } + function f4(x) { return !1; } + function f5(x) { return; } + function f6(x) { return "number"; } + + function g1() { return g(), -1; } + function g2() { return g(), 2; } + function g3() { return g(), -4; } + function g4() { return g(), !1; } + function g5() { return g(), void 0; } + function g6() { return g(), "number"; } + } +} -- cgit v1.2.3