2016-04-26 09:43:03 +00:00
|
|
|
multiple_functions: {
|
2017-05-27 05:41:49 +00:00
|
|
|
options = {
|
|
|
|
|
hoist_funs: false,
|
|
|
|
|
if_return: true,
|
|
|
|
|
}
|
2016-04-23 21:48:33 +00:00
|
|
|
input: {
|
|
|
|
|
( function() {
|
|
|
|
|
if ( !window ) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
function f() {}
|
|
|
|
|
function g() {}
|
|
|
|
|
} )();
|
|
|
|
|
}
|
|
|
|
|
expect: {
|
|
|
|
|
( function() {
|
|
|
|
|
// NOTE: other compression steps will reduce this
|
|
|
|
|
// down to just `window`.
|
|
|
|
|
if ( window );
|
2017-05-27 05:41:49 +00:00
|
|
|
function f() {}
|
|
|
|
|
function g() {}
|
2016-04-23 21:48:33 +00:00
|
|
|
} )();
|
|
|
|
|
}
|
|
|
|
|
}
|
2016-04-26 09:43:03 +00:00
|
|
|
|
|
|
|
|
single_function: {
|
2017-05-27 05:41:49 +00:00
|
|
|
options = {
|
|
|
|
|
hoist_funs: false,
|
|
|
|
|
if_return: true,
|
|
|
|
|
}
|
2016-04-26 09:43:03 +00:00
|
|
|
input: {
|
|
|
|
|
( function() {
|
|
|
|
|
if ( !window ) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
function f() {}
|
|
|
|
|
} )();
|
|
|
|
|
}
|
|
|
|
|
expect: {
|
|
|
|
|
( function() {
|
|
|
|
|
if ( window );
|
2017-05-27 05:41:49 +00:00
|
|
|
function f() {}
|
2016-04-26 09:43:03 +00:00
|
|
|
} )();
|
|
|
|
|
}
|
|
|
|
|
}
|
2016-04-26 09:49:55 +00:00
|
|
|
|
|
|
|
|
deeply_nested: {
|
2017-05-27 05:41:49 +00:00
|
|
|
options = {
|
|
|
|
|
hoist_funs: false,
|
|
|
|
|
if_return: true,
|
|
|
|
|
}
|
2016-04-26 09:49:55 +00:00
|
|
|
input: {
|
|
|
|
|
( function() {
|
|
|
|
|
if ( !window ) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
function f() {}
|
|
|
|
|
function g() {}
|
|
|
|
|
if ( !document ) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
function h() {}
|
|
|
|
|
} )();
|
|
|
|
|
}
|
|
|
|
|
expect: {
|
|
|
|
|
( function() {
|
|
|
|
|
// NOTE: other compression steps will reduce this
|
|
|
|
|
// down to just `window`.
|
|
|
|
|
if ( window )
|
|
|
|
|
if (document);
|
2017-05-27 05:41:49 +00:00
|
|
|
function f() {}
|
|
|
|
|
function g() {}
|
|
|
|
|
function h() {}
|
2016-04-26 09:49:55 +00:00
|
|
|
} )();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
not_hoisted_when_already_nested: {
|
2017-05-27 05:41:49 +00:00
|
|
|
options = {
|
|
|
|
|
hoist_funs: false,
|
|
|
|
|
if_return: true,
|
|
|
|
|
}
|
2016-04-26 09:49:55 +00:00
|
|
|
input: {
|
|
|
|
|
( function() {
|
|
|
|
|
if ( !window ) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
if ( foo ) function f() {}
|
|
|
|
|
} )();
|
|
|
|
|
}
|
|
|
|
|
expect: {
|
|
|
|
|
( function() {
|
|
|
|
|
if ( window )
|
|
|
|
|
if ( foo ) function f() {}
|
|
|
|
|
} )();
|
|
|
|
|
}
|
|
|
|
|
}
|
2017-05-27 05:41:49 +00:00
|
|
|
|
|
|
|
|
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;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|