Skip to content
Snippets Groups Projects
Commit 8b506020 authored by André Bargull's avatar André Bargull Committed by Rick Waldron
Browse files

Replace Annex-B __proto__ with Object.[gs]etPrototypeOf

parent f3911d7a
No related branches found
No related tags found
No related merge requests found
......@@ -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]);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment