From: Richard van Velzen Date: Tue, 26 Apr 2016 09:49:55 +0000 (+0200) Subject: Add test cases for slightly more esoteric cases X-Git-Url: https://git.ndcode.org/public/gitweb.cgi?a=commitdiff_plain;h=e9224ab4441ddb352566a52b84f1384bf5b8a8d8;p=UglifyJS.git Add test cases for slightly more esoteric cases --- 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() {} + } )(); + } +}