2020-06-04 14:48:36 +02:00
|
|
|
load("test-common.js");
|
|
|
|
|
|
|
|
|
|
try {
|
2020-07-05 09:27:00 -07:00
|
|
|
var callHoisted = hoisted();
|
|
|
|
|
function hoisted() {
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
assert(hoisted() === true);
|
|
|
|
|
assert(callHoisted === true);
|
2020-06-04 14:48:36 +02:00
|
|
|
|
2020-07-05 09:27:00 -07:00
|
|
|
{
|
|
|
|
|
var callScopedHoisted = scopedHoisted();
|
|
|
|
|
function scopedHoisted() {
|
|
|
|
|
return "foo";
|
2020-06-04 14:48:36 +02:00
|
|
|
}
|
|
|
|
|
assert(scopedHoisted() === "foo");
|
|
|
|
|
assert(callScopedHoisted === "foo");
|
2020-07-05 09:27:00 -07:00
|
|
|
}
|
|
|
|
|
assert(scopedHoisted() === "foo");
|
|
|
|
|
assert(callScopedHoisted === "foo");
|
2020-06-04 14:48:36 +02:00
|
|
|
|
2020-07-05 09:27:00 -07:00
|
|
|
const test = () => {
|
|
|
|
|
var iife = (function () {
|
|
|
|
|
return declaredLater();
|
|
|
|
|
})();
|
|
|
|
|
function declaredLater() {
|
|
|
|
|
return "yay";
|
|
|
|
|
}
|
|
|
|
|
return iife;
|
|
|
|
|
};
|
|
|
|
|
assert(typeof declaredLater === "undefined");
|
|
|
|
|
assert(test() === "yay");
|
2020-06-04 14:48:36 +02:00
|
|
|
|
2020-07-05 09:27:00 -07:00
|
|
|
console.log("PASS");
|
2020-06-04 14:48:36 +02:00
|
|
|
} catch (e) {
|
2020-07-05 09:27:00 -07:00
|
|
|
console.log("FAIL: " + e);
|
2020-06-04 14:48:36 +02:00
|
|
|
}
|