mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 16:37:47 +00:00
LibJS: Return non-object argument unaltered from Object.setPrototypeOf()
This was missing step 3 from the spec: 3. If Type(O) is not Object, return O. Also use RequireObjectCoercible() for a better error message and make the rest of the code a bit easier to read and more similar to the spec text.
This commit is contained in:
parent
1f8b6ac3c3
commit
8a06a93ce2
2 changed files with 18 additions and 11 deletions
|
@ -9,6 +9,13 @@ describe("correct behavior", () => {
|
|||
expect(Object.setPrototypeOf(o, p)).toBe(o);
|
||||
expect(Object.getPrototypeOf(o)).toBe(p);
|
||||
});
|
||||
|
||||
test("non-object argument is returned without being coerced to object", () => {
|
||||
let o = 42;
|
||||
let p = {};
|
||||
expect(Object.setPrototypeOf(o, p)).toBe(o);
|
||||
expect(Object.getPrototypeOf(o)).toBe(Number.prototype);
|
||||
});
|
||||
});
|
||||
|
||||
describe("errors", () => {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue