mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 18:58:12 +00:00
LibJS: Add a global "Object" constructor
This patch adds an "Object" constructor to the global object. The only function it implements so far is Object.getPrototypeOf().
This commit is contained in:
parent
a3d92b1210
commit
14047ca432
9 changed files with 134 additions and 3 deletions
11
Libraries/LibJS/Tests/Object.getPrototypeOf.js
Normal file
11
Libraries/LibJS/Tests/Object.getPrototypeOf.js
Normal file
|
@ -0,0 +1,11 @@
|
|||
function assert(x) { if (!x) throw 1; }
|
||||
|
||||
try {
|
||||
var o1 = new Object();
|
||||
var o2 = {};
|
||||
assert(Object.getPrototypeOf(o1) === Object.getPrototypeOf(o2));
|
||||
assert(Object.getPrototypeOf(Object.getPrototypeOf(o1)) === null);
|
||||
console.log("PASS");
|
||||
} catch (e) {
|
||||
console.log("FAIL: " + e);
|
||||
}
|
10
Libraries/LibJS/Tests/Object.prototype.js
Normal file
10
Libraries/LibJS/Tests/Object.prototype.js
Normal file
|
@ -0,0 +1,10 @@
|
|||
function assert(x) { if (!x) throw 1; }
|
||||
|
||||
try {
|
||||
var o = new Object();
|
||||
Object.prototype.foo = 123;
|
||||
assert(o.foo === 123);
|
||||
console.log("PASS");
|
||||
} catch (e) {
|
||||
console.log("FAIL: " + e);
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue