From e9224ab4441ddb352566a52b84f1384bf5b8a8d8 Mon Sep 17 00:00:00 2001 From: Richard van Velzen Date: Tue, 26 Apr 2016 11:49:55 +0200 Subject: [PATCH] Add test cases for slightly more esoteric cases --- test/compress/issue-1052.js | 53 +++++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) diff --git a/test/compress/issue-1052.js b/test/compress/issue-1052.js index bad28a8f..0a77f006 100644 --- a/test/compress/issue-1052.js +++ b/test/compress/issue-1052.js @@ -41,3 +41,56 @@ single_function: { } )(); } } + +deeply_nested: { + options = { if_return: true, hoist_funs: false }; + input: { + ( function() { + if ( !window ) { + return; + } + + function f() {} + function g() {} + + if ( !document ) { + return; + } + + function h() {} + } )(); + } + expect: { + ( function() { + function f() {} + function g() {} + + function h() {} + + // NOTE: other compression steps will reduce this + // down to just `window`. + if ( window ) + if (document); + } )(); + } +} + +not_hoisted_when_already_nested: { + options = { if_return: true, hoist_funs: false }; + input: { + ( function() { + if ( !window ) { + return; + } + + if ( foo ) function f() {} + + } )(); + } + expect: { + ( function() { + if ( window ) + if ( foo ) function f() {} + } )(); + } +} -- 2.34.1