mirror of https://github.com/tc39/test262.git
Replace Annex-B __proto__ with Object.[gs]etPrototypeOf
This commit is contained in:
parent
f3911d7ae4
commit
8b50602099
|
@ -27,11 +27,11 @@ class FakeRegExp extends RegExp {
|
|||
|
||||
const re = new FakeRegExp();
|
||||
const result = re.exec("ab");
|
||||
assert.sameValue(result.__proto__, Array.prototype);
|
||||
assert.sameValue(Object.getPrototypeOf(result), Array.prototype);
|
||||
assert.sameValue(false, result.hasOwnProperty("groups"));
|
||||
|
||||
Array.prototype.groups = { a: "b" };
|
||||
Array.prototype.groups.__proto__.b = "c";
|
||||
Object.getPrototypeOf(Array.prototype.groups).b = "c";
|
||||
assert.sameValue("b", "ab".replace(re, "$<a>"));
|
||||
assert.sameValue("c", "ab".replace(re, "$<b>"));
|
||||
Array.prototype.groups = undefined;
|
||||
|
|
|
@ -21,14 +21,14 @@ class FakeRegExp extends RegExp {
|
|||
const fakeResult = ["ab", "a"];
|
||||
fakeResult.index = 0;
|
||||
fakeResult.groups = { a: "b" };
|
||||
fakeResult.groups.__proto__.b = "c";
|
||||
Object.getPrototypeOf(fakeResult.groups).b = "c";
|
||||
return fakeResult;
|
||||
}
|
||||
};
|
||||
|
||||
const re = new FakeRegExp();
|
||||
const result = re.exec("ab");
|
||||
assert.sameValue(result.__proto__, Array.prototype);
|
||||
assert.sameValue(Object.getPrototypeOf(result), Array.prototype);
|
||||
assert(result.hasOwnProperty("groups"));
|
||||
assert.sameValue("b", result.groups.a);
|
||||
assert.sameValue("b", "ab".replace(re, "$<a>"));
|
||||
|
|
|
@ -17,7 +17,7 @@ info: |
|
|||
|
||||
const re = /./;
|
||||
const result = re.exec("a");
|
||||
assert.sameValue(result.__proto__, Array.prototype);
|
||||
assert.sameValue(Object.getPrototypeOf(result), Array.prototype);
|
||||
assert(result.hasOwnProperty("groups"));
|
||||
assert.sameValue("a", result[0]);
|
||||
assert.sameValue(0, result.index);
|
||||
|
|
|
@ -18,7 +18,7 @@ info: |
|
|||
|
||||
const re = /(?<a>a).|(?<x>x)/;
|
||||
const result = re.exec("ab");
|
||||
assert.sameValue(result.__proto__, Array.prototype);
|
||||
assert.sameValue(Object.getPrototypeOf(result), Array.prototype);
|
||||
assert(result.hasOwnProperty("groups"));
|
||||
assert.sameValue("ab", result[0]);
|
||||
assert.sameValue("a", result[1]);
|
||||
|
|
Loading…
Reference in New Issue