mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 23:27:35 +00:00
LibJS: Always access RegExp flags by its "flags" property
This is a normative change in the ECMA-262 spec. See:
35b7eb2
Note there is a bit of weirdness between the mainline spec and the set
notation proposal as the latter has not been updated with this change.
For now, this implements what the spec PR and other prototypes indicate
how the proposal will behave.
This commit is contained in:
parent
9a1f55afe5
commit
a803d9226f
3 changed files with 78 additions and 25 deletions
|
@ -0,0 +1,27 @@
|
|||
describe("basic functionality", () => {
|
||||
test("uses flags property instead of individual property lookups", () => {
|
||||
let accessedFlags = false;
|
||||
let accessedGlobal = false;
|
||||
let accessedUnicode = false;
|
||||
|
||||
class RegExp1 extends RegExp {
|
||||
get flags() {
|
||||
accessedFlags = true;
|
||||
return "g";
|
||||
}
|
||||
get global() {
|
||||
accessedGlobal = true;
|
||||
return false;
|
||||
}
|
||||
get unicode() {
|
||||
accessedUnicode = true;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
RegExp.prototype[Symbol.match].call(new RegExp1("foo"));
|
||||
expect(accessedFlags).toBeTrue();
|
||||
expect(accessedGlobal).toBeFalse();
|
||||
expect(accessedUnicode).toBeFalse();
|
||||
});
|
||||
});
|
|
@ -0,0 +1,27 @@
|
|||
describe("basic functionality", () => {
|
||||
test("uses flags property instead of individual property lookups", () => {
|
||||
let accessedFlags = false;
|
||||
let accessedGlobal = false;
|
||||
let accessedUnicode = false;
|
||||
|
||||
class RegExp1 extends RegExp {
|
||||
get flags() {
|
||||
accessedFlags = true;
|
||||
return "g";
|
||||
}
|
||||
get global() {
|
||||
accessedGlobal = true;
|
||||
return false;
|
||||
}
|
||||
get unicode() {
|
||||
accessedUnicode = true;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
RegExp.prototype[Symbol.replace].call(new RegExp1("foo"));
|
||||
expect(accessedFlags).toBeTrue();
|
||||
expect(accessedGlobal).toBeFalse();
|
||||
expect(accessedUnicode).toBeFalse();
|
||||
});
|
||||
});
|
Loading…
Add table
Add a link
Reference in a new issue