1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-10 08:47:35 +00:00

LibJS: Convert all remaining non-Array tests to the new system :)

This commit is contained in:
Matthew Olsson 2020-07-05 17:26:26 -07:00 committed by Andreas Kling
parent 918f4affd5
commit 15de2eda2b
72 changed files with 2394 additions and 1998 deletions

View file

@ -1,24 +1,29 @@
load("test-common.js");
try {
var callHoisted = hoisted();
test("basic functionality", () => {
let callHoisted = hoisted();
function hoisted() {
return true;
return "foo";
}
assert(hoisted() === true);
assert(callHoisted === true);
expect(hoisted()).toBe("foo");
expect(callHoisted).toBe("foo");
});
// First two calls produce a ReferenceError, but the declarations should be hoisted
test.skip("functions are hoisted across non-lexical scopes", () => {
expect(scopedHoisted).toBeUndefined();
expect(callScopedHoisted).toBeUndefined();
{
var callScopedHoisted = scopedHoisted();
function scopedHoisted() {
return "foo";
}
assert(scopedHoisted() === "foo");
assert(callScopedHoisted === "foo");
expect(scopedHoisted()).toBe("foo");
expect(callScopedHoisted).toBe("foo");
}
assert(scopedHoisted() === "foo");
assert(callScopedHoisted === "foo");
expect(scopedHoisted()).toBe("foo");
expect(callScopedHoisted).toBe("foo");
});
test("functions are not hoisted across lexical scopes", () => {
const test = () => {
var iife = (function () {
return declaredLater();
@ -28,10 +33,7 @@ try {
}
return iife;
};
assert(typeof declaredLater === "undefined");
assert(test() === "yay");
console.log("PASS");
} catch (e) {
console.log("FAIL: " + e);
}
expect(() => declaredLater).toThrow(ReferenceError);
expect(test()).toBe("yay");
});