mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 844882 - Part 5: jit-tests for self-hosted classes. (r=nmatsakis)
This commit is contained in:
parent
fe6febba0f
commit
af0e73008e
37
js/src/jit-test/tests/self-hosting/self-hosted-class.js
Normal file
37
js/src/jit-test/tests/self-hosting/self-hosted-class.js
Normal file
@ -0,0 +1,37 @@
|
||||
var NewClassPrototype = getSelfHostedValue("NewClassPrototype");
|
||||
var NewObjectWithClassPrototype = getSelfHostedValue("NewObjectWithClassPrototype");
|
||||
var HaveSameClass = getSelfHostedValue("HaveSameClass");
|
||||
var UnsafeGetReservedSlot = getSelfHostedValue("UnsafeGetReservedSlot");
|
||||
var UnsafeSetReservedSlot = getSelfHostedValue("UnsafeSetReservedSlot");
|
||||
|
||||
var numSlots = 5;
|
||||
var C = NewClassPrototype(numSlots);
|
||||
|
||||
C.getSlots = function getSlots() {
|
||||
if (!HaveSameClass(this, C))
|
||||
throw TypeError("bad class");
|
||||
var slots = [];
|
||||
for (var i = 0; i < numSlots; i++)
|
||||
slots.push(UnsafeGetReservedSlot(this, i));
|
||||
return slots;
|
||||
};
|
||||
|
||||
C.setSlots = function setSlots(slots) {
|
||||
if (!HaveSameClass(this, C))
|
||||
throw TypeError("bad class");
|
||||
for (var i = 0; i < numSlots; i++)
|
||||
UnsafeSetReservedSlot(this, i, slots[i]);
|
||||
};
|
||||
|
||||
function f() {
|
||||
var obj = NewObjectWithClassPrototype(C);
|
||||
var before = ["foo", 2.22, ["bar", "baz"], { x: 0, y: -1.1 }, false];
|
||||
obj.setSlots(before);
|
||||
var after = obj.getSlots();
|
||||
|
||||
assertEq(before.length, after.length);
|
||||
for (var i = 0; i < before.length; i++)
|
||||
assertEq(before[i], after[i]);
|
||||
}
|
||||
|
||||
f();
|
Loading…
Reference in New Issue
Block a user