mirror of
https://github.com/tc39/test262.git
synced 2025-05-03 22:40:28 +02:00
* [javascriptcore-test262-automation] changes from git@github.com:WebKit/webkit.git at sha 949e26452cfa153a7f4afe593da97e2fe9e1b706 on Tue Jul 03 2018 14:35:15 GMT-0400 (Eastern Daylight Time)
54 lines
1.1 KiB
JavaScript
54 lines
1.1 KiB
JavaScript
let y = 42;
|
|
function makePolyProtoInstance() {
|
|
function foo() {
|
|
class C {
|
|
constructor() { this.x = 20; }
|
|
};
|
|
C.prototype.y = y;
|
|
return new C;
|
|
}
|
|
|
|
for (let i = 0; i < 5; ++i)
|
|
foo();
|
|
return foo();
|
|
}
|
|
|
|
let polyProtoInstance = makePolyProtoInstance();
|
|
String.prototype.__proto__ = polyProtoInstance;
|
|
Symbol.prototype.__proto__ = polyProtoInstance;
|
|
let strings = [
|
|
"foo",
|
|
Symbol("foo"),
|
|
"bar",
|
|
Symbol("bar"),
|
|
];
|
|
|
|
function assert(b) {
|
|
if (!b)
|
|
throw new Error("Bad asssertion")
|
|
}
|
|
noInline(assert);
|
|
|
|
function validate(s) {
|
|
assert(s.x === 20);
|
|
assert(s.y === y);
|
|
assert(s.nonExistentProperty === undefined);
|
|
assert(typeof s.hasOwnProperty === "function");
|
|
assert(s.hasOwnProperty === Object.prototype.hasOwnProperty);
|
|
}
|
|
noInline(validate);
|
|
|
|
for (let i = 0; i < 1000; ++i) {
|
|
for (let s of strings) {
|
|
validate(s);
|
|
}
|
|
}
|
|
|
|
y = 27;
|
|
polyProtoInstance.__proto__ = {z:400, y: y};
|
|
for (let i = 0; i < 1000; ++i) {
|
|
for (let s of strings) {
|
|
validate(s);
|
|
}
|
|
}
|