diff options
Diffstat (limited to 'test/compress/issue-1052.js')
-rw-r--r-- | test/compress/issue-1052.js | 88 |
1 files changed, 67 insertions, 21 deletions
diff --git a/test/compress/issue-1052.js b/test/compress/issue-1052.js index 0a77f006..e3dc7322 100644 --- a/test/compress/issue-1052.js +++ b/test/compress/issue-1052.js @@ -1,90 +1,91 @@ multiple_functions: { - options = { if_return: true, hoist_funs: false }; + options = { + hoist_funs: false, + if_return: true, + } input: { ( function() { if ( !window ) { return; } - function f() {} function g() {} } )(); } expect: { ( function() { - function f() {} - function g() {} - // NOTE: other compression steps will reduce this // down to just `window`. if ( window ); + function f() {} + function g() {} } )(); } } single_function: { - options = { if_return: true, hoist_funs: false }; + options = { + hoist_funs: false, + if_return: true, + } input: { ( function() { if ( !window ) { return; } - function f() {} } )(); } expect: { ( function() { - function f() {} - if ( window ); + function f() {} } )(); } } deeply_nested: { - options = { if_return: true, hoist_funs: false }; + options = { + hoist_funs: false, + if_return: true, + } 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); + function f() {} + function g() {} + function h() {} } )(); } } not_hoisted_when_already_nested: { - options = { if_return: true, hoist_funs: false }; + options = { + hoist_funs: false, + if_return: true, + } input: { ( function() { if ( !window ) { return; } - if ( foo ) function f() {} - } )(); } expect: { @@ -94,3 +95,48 @@ not_hoisted_when_already_nested: { } )(); } } + +defun_if_return: { + options = { + hoist_funs: false, + if_return: true, + } + input: { + function e() { + function f() {} + if (!window) return; + else function g() {} + function h() {} + } + } + expect: { + function e() { + function f() {} + if (window) function g() {} + function h() {} + } + } +} + +defun_hoist_funs: { + options = { + hoist_funs: true, + if_return: true, + } + input: { + function e() { + function f() {} + if (!window) return; + else function g() {} + function h() {} + } + } + expect: { + function e() { + function f() {} + function g() {} + function h() {} + !window; + } + } +} |