From ac0086a74521ffce97b6e8bde0bee54feb0c5ec9 Mon Sep 17 00:00:00 2001 From: Matt Basta Date: Thu, 6 Feb 2014 12:39:13 -0800 Subject: Simplify nested conditionals if possible --- test/compress/conditionals.js | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) (limited to 'test/compress') diff --git a/test/compress/conditionals.js b/test/compress/conditionals.js index 9ef30ac1..213b246b 100644 --- a/test/compress/conditionals.js +++ b/test/compress/conditionals.js @@ -205,3 +205,30 @@ cond_4: { some_condition(), do_something(); } } + +cond_5: { + options = { + conditionals: true + }; + input: { + if (some_condition()) { + if (some_other_condition()) { + do_something(); + } else { + alternate(); + } + } else { + alternate(); + } + + if (some_condition()) { + if (some_other_condition()) { + do_something(); + } + } + } + expect: { + some_condition() && some_other_condition() ? do_something() : alternate(); + some_condition() && some_other_condition() && do_something(); + } +} -- cgit v1.2.3