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: {
|
2022-02-12 15:18:07 +00:00
|
|
|
(function() {
|
|
|
|
|
if (!window)
|
2016-04-23 21:48:33 +00:00
|
|
|
return;
|
|
|
|
|
function f() {}
|
|
|
|
|
function g() {}
|
2022-02-12 15:18:07 +00:00
|
|
|
})();
|
2016-04-23 21:48:33 +00:00
|
|
|
}
|
|
|
|
|
expect: {
|
2022-02-12 15:18:07 +00:00
|
|
|
(function() {
|
2016-04-23 21:48:33 +00:00
|
|
|
// NOTE: other compression steps will reduce this
|
|
|
|
|
// down to just `window`.
|
2022-02-12 15:18:07 +00:00
|
|
|
if (!window);
|
2017-05-27 05:41:49 +00:00
|
|
|
function f() {}
|
|
|
|
|
function g() {}
|
2022-02-12 15:18:07 +00:00
|
|
|
})();
|
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: {
|
2022-02-12 15:18:07 +00:00
|
|
|
(function() {
|
|
|
|
|
if (!window)
|
2016-04-26 09:43:03 +00:00
|
|
|
return;
|
|
|
|
|
function f() {}
|
2022-02-12 15:18:07 +00:00
|
|
|
})();
|
2016-04-26 09:43:03 +00:00
|
|
|
}
|
|
|
|
|
expect: {
|
2022-02-12 15:18:07 +00:00
|
|
|
(function() {
|
|
|
|
|
if (!window);
|
2017-05-27 05:41:49 +00:00
|
|
|
function f() {}
|
2022-02-12 15:18:07 +00:00
|
|
|
})();
|
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: {
|
2022-02-12 15:18:07 +00:00
|
|
|
(function() {
|
|
|
|
|
if (!window)
|
2016-04-26 09:49:55 +00:00
|
|
|
return;
|
|
|
|
|
function f() {}
|
|
|
|
|
function g() {}
|
2022-02-12 15:18:07 +00:00
|
|
|
if (!document)
|
2016-04-26 09:49:55 +00:00
|
|
|
return;
|
|
|
|
|
function h() {}
|
2022-02-12 15:18:07 +00:00
|
|
|
})();
|
2016-04-26 09:49:55 +00:00
|
|
|
}
|
|
|
|
|
expect: {
|
2022-02-12 15:18:07 +00:00
|
|
|
(function() {
|
2016-04-26 09:49:55 +00:00
|
|
|
// NOTE: other compression steps will reduce this
|
|
|
|
|
// down to just `window`.
|
2022-02-12 15:18:07 +00:00
|
|
|
if (!window);
|
|
|
|
|
else if (!document);
|
2017-05-27 05:41:49 +00:00
|
|
|
function f() {}
|
|
|
|
|
function g() {}
|
|
|
|
|
function h() {}
|
2022-02-12 15:18:07 +00:00
|
|
|
})();
|
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: {
|
2022-02-12 15:18:07 +00:00
|
|
|
(function() {
|
|
|
|
|
if (!window)
|
2016-04-26 09:49:55 +00:00
|
|
|
return;
|
2022-02-12 15:18:07 +00:00
|
|
|
if (foo) function f() {}
|
|
|
|
|
})();
|
2016-04-26 09:49:55 +00:00
|
|
|
}
|
|
|
|
|
expect: {
|
2022-02-12 15:18:07 +00:00
|
|
|
(function() {
|
|
|
|
|
if (!window);
|
|
|
|
|
else if (foo)
|
|
|
|
|
function f() {}
|
|
|
|
|
})();
|
2016-04-26 09:49:55 +00:00
|
|
|
}
|
|
|
|
|
}
|
2017-05-27 05:41:49 +00:00
|
|
|
|
|
|
|
|
defun_if_return: {
|
|
|
|
|
options = {
|
|
|
|
|
hoist_funs: false,
|
|
|
|
|
if_return: true,
|
|
|
|
|
}
|
|
|
|
|
input: {
|
|
|
|
|
function e() {
|
|
|
|
|
function f() {}
|
2022-02-12 15:18:07 +00:00
|
|
|
if (!window)
|
|
|
|
|
return;
|
|
|
|
|
else
|
|
|
|
|
function g() {}
|
2017-05-27 05:41:49 +00:00
|
|
|
function h() {}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
expect: {
|
|
|
|
|
function e() {
|
|
|
|
|
function f() {}
|
2022-02-12 15:18:07 +00:00
|
|
|
if (!window);
|
|
|
|
|
else
|
|
|
|
|
function g() {}
|
2017-05-27 05:41:49 +00:00
|
|
|
function h() {}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
defun_hoist_funs: {
|
|
|
|
|
options = {
|
|
|
|
|
hoist_funs: true,
|
|
|
|
|
if_return: true,
|
|
|
|
|
}
|
|
|
|
|
input: {
|
|
|
|
|
function e() {
|
|
|
|
|
function f() {}
|
2022-02-12 15:18:07 +00:00
|
|
|
if (!window)
|
|
|
|
|
return;
|
|
|
|
|
else
|
|
|
|
|
function g() {}
|
2017-05-27 05:41:49 +00:00
|
|
|
function h() {}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
expect: {
|
|
|
|
|
function e() {
|
|
|
|
|
function f() {}
|
|
|
|
|
function g() {}
|
|
|
|
|
function h() {}
|
2022-02-12 15:18:07 +00:00
|
|
|
if (!window);
|
2017-05-29 02:51:41 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
defun_else_if_return: {
|
|
|
|
|
options = {
|
|
|
|
|
hoist_funs: false,
|
|
|
|
|
if_return: true,
|
|
|
|
|
}
|
|
|
|
|
input: {
|
|
|
|
|
function e() {
|
|
|
|
|
function f() {}
|
2022-02-12 15:18:07 +00:00
|
|
|
if (window)
|
|
|
|
|
function g() {}
|
|
|
|
|
else
|
|
|
|
|
return;
|
2017-05-29 02:51:41 +00:00
|
|
|
function h() {}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
expect: {
|
|
|
|
|
function e() {
|
|
|
|
|
function f() {}
|
2022-02-12 15:18:07 +00:00
|
|
|
if (window)
|
|
|
|
|
function g() {}
|
2017-05-29 02:51:41 +00:00
|
|
|
function h() {}
|
2017-05-27 05:41:49 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|