mirror of
https://repo.dactyloidae.xyz/Dactyloidae/UXP.git
synced 2026-09-06 07:48:38 +09:00
Remove unboxed object tests.
This commit is contained in:
parent
05daa3c420
commit
30b5b0a6da
6 changed files with 0 additions and 187 deletions
|
|
@ -1,49 +0,0 @@
|
|||
|
||||
function Foo(a, b) {
|
||||
this.a = a;
|
||||
this.b = b;
|
||||
}
|
||||
|
||||
function invalidate_foo() {
|
||||
var a = [];
|
||||
var counter = 0;
|
||||
for (var i = 0; i < 50; i++)
|
||||
a.push(new Foo(i, i + 1));
|
||||
Object.defineProperty(Foo.prototype, "a", {configurable: true, set: function() { counter++; }});
|
||||
for (var i = 0; i < 50; i++)
|
||||
a.push(new Foo(i, i + 1));
|
||||
delete Foo.prototype.a;
|
||||
var total = 0;
|
||||
for (var i = 0; i < a.length; i++) {
|
||||
assertEq('a' in a[i], i < 50);
|
||||
total += a[i].b;
|
||||
}
|
||||
assertEq(total, 2550);
|
||||
assertEq(counter, 50);
|
||||
}
|
||||
invalidate_foo();
|
||||
|
||||
function Bar(a, b, fn) {
|
||||
this.a = a;
|
||||
if (b == 30)
|
||||
Object.defineProperty(Bar.prototype, "b", {configurable: true, set: fn});
|
||||
this.b = b;
|
||||
}
|
||||
|
||||
function invalidate_bar() {
|
||||
var a = [];
|
||||
var counter = 0;
|
||||
function fn() { counter++; }
|
||||
for (var i = 0; i < 50; i++)
|
||||
a.push(new Bar(i, i + 1, fn));
|
||||
delete Bar.prototype.b;
|
||||
var total = 0;
|
||||
for (var i = 0; i < a.length; i++) {
|
||||
assertEq('a' in a[i], true);
|
||||
assertEq('b' in a[i], i < 29);
|
||||
total += a[i].a;
|
||||
}
|
||||
assertEq(total, 1225);
|
||||
assertEq(counter, 21);
|
||||
}
|
||||
invalidate_bar();
|
||||
|
|
@ -1,47 +0,0 @@
|
|||
|
||||
// Test various ways of converting an unboxed object to native.
|
||||
|
||||
function Foo(a, b) {
|
||||
this.a = a;
|
||||
this.b = b;
|
||||
}
|
||||
|
||||
var proxyObj = {
|
||||
get: function(recipient, name) {
|
||||
return recipient[name] + 2;
|
||||
}
|
||||
};
|
||||
|
||||
function f() {
|
||||
var a = [];
|
||||
for (var i = 0; i < 50; i++)
|
||||
a.push(new Foo(i, i + 1));
|
||||
|
||||
var prop = "a";
|
||||
|
||||
i = 0;
|
||||
for (; i < 5; i++)
|
||||
a[i].c = i;
|
||||
for (; i < 10; i++)
|
||||
Object.defineProperty(a[i], 'c', {value: i});
|
||||
for (; i < 15; i++)
|
||||
a[i] = new Proxy(a[i], proxyObj);
|
||||
for (; i < 20; i++)
|
||||
a[i].a = 3.5;
|
||||
for (; i < 25; i++)
|
||||
delete a[i].b;
|
||||
for (; i < 30; i++)
|
||||
a[prop] = 4;
|
||||
|
||||
var total = 0;
|
||||
for (i = 0; i < a.length; i++) {
|
||||
if ('a' in a[i])
|
||||
total += a[i].a;
|
||||
if ('b' in a[i])
|
||||
total += a[i].b;
|
||||
if ('c' in a[i])
|
||||
total += a[i].c;
|
||||
}
|
||||
assertEq(total, 2382.5);
|
||||
}
|
||||
f();
|
||||
|
|
@ -1,20 +0,0 @@
|
|||
|
||||
function f() {
|
||||
var propNames = ["a","b","c","d","e","f","g","h","i","j","x","y"];
|
||||
var arr = [];
|
||||
for (var i=0; i<64; i++)
|
||||
arr.push({x:1, y:2});
|
||||
for (var i=0; i<64; i++) {
|
||||
// Make sure there are expandos with dynamic slots for each object.
|
||||
for (var j = 0; j < propNames.length; j++)
|
||||
arr[i][propNames[j]] = j;
|
||||
}
|
||||
var res = 0;
|
||||
for (var i=0; i<100000; i++) {
|
||||
var o = arr[i % 64];
|
||||
var p = propNames[i % propNames.length];
|
||||
res += o[p];
|
||||
}
|
||||
assertEq(res, 549984);
|
||||
}
|
||||
f();
|
||||
|
|
@ -1,31 +0,0 @@
|
|||
|
||||
// Use the correct receiver when non-native objects are prototypes of other objects.
|
||||
|
||||
function Thing(a, b) {
|
||||
this.a = a;
|
||||
this.b = b;
|
||||
}
|
||||
|
||||
function foo() {
|
||||
var array = [];
|
||||
for (var i = 0; i < 10000; i++)
|
||||
array.push(new Thing(i, i + 1));
|
||||
|
||||
var proto = new Thing(1, 2);
|
||||
var obj = Object.create(proto);
|
||||
|
||||
Object.defineProperty(Thing.prototype, "c", {set:function() { this.d = 0; }});
|
||||
obj.c = 3;
|
||||
assertEq(obj.c, undefined);
|
||||
assertEq(obj.d, 0);
|
||||
assertEq(obj.hasOwnProperty("d"), true);
|
||||
assertEq(proto.d, undefined);
|
||||
assertEq(proto.hasOwnProperty("d"), false);
|
||||
|
||||
obj.a = 3;
|
||||
assertEq(obj.a, 3);
|
||||
assertEq(proto.a, 1);
|
||||
assertEq(obj.hasOwnProperty("a"), true);
|
||||
}
|
||||
|
||||
foo();
|
||||
|
|
@ -1,24 +0,0 @@
|
|||
function O() {
|
||||
this.x = 1;
|
||||
this.y = 2;
|
||||
}
|
||||
function testUnboxed() {
|
||||
var arr = [];
|
||||
for (var i=0; i<100; i++)
|
||||
arr.push(new O);
|
||||
|
||||
var o = arr[arr.length-1];
|
||||
o[0] = 0;
|
||||
o[2] = 2;
|
||||
var sym = Symbol();
|
||||
o[sym] = 1;
|
||||
o.z = 3;
|
||||
Object.defineProperty(o, '3', {value:1,enumerable:false,configurable:false,writable:false});
|
||||
o[4] = 4;
|
||||
|
||||
var props = Reflect.ownKeys(o);
|
||||
assertEq(props[props.length-1], sym);
|
||||
|
||||
assertEq(Object.getOwnPropertyNames(o).join(""), "0234xyz");
|
||||
}
|
||||
testUnboxed();
|
||||
|
|
@ -1,16 +0,0 @@
|
|||
|
||||
var a = [];
|
||||
for (var i = 0; i < 2000; i++)
|
||||
a.push({f:i});
|
||||
|
||||
function f() {
|
||||
var total = 0;
|
||||
for (var i = 0; i < a.length; i++)
|
||||
total += a[i].f;
|
||||
return total;
|
||||
}
|
||||
assertEq(f(), 1999000);
|
||||
|
||||
var sub = Object.create(a[0]);
|
||||
|
||||
assertEq(f(), 1999000);
|
||||
Loading…
Add table
Add a link
Reference in a new issue