1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 14:17:36 +00:00

LibJS: Make RegExp() constructor spec-compliant

- Default values should depend on arguments being undefined, not being
  missing
- "(?:)" for empty pattern happens in RegExp.prototype.source, not the
  constructor
This commit is contained in:
Linus Groh 2020-11-27 22:42:41 +00:00 committed by Andreas Kling
parent 99536449d5
commit 5cb45e4feb
2 changed files with 21 additions and 8 deletions

View file

@ -0,0 +1,9 @@
test("basic functionality", () => {
// FIXME: update when toString is spec-compliant
expect(RegExp().toString()).toBe("//");
expect(RegExp(undefined).toString()).toBe("//");
expect(RegExp("foo").toString()).toBe("/foo/");
expect(RegExp("foo", undefined).toString()).toBe("/foo/");
expect(RegExp("foo", "g").toString()).toBe("/foo/g");
expect(RegExp(undefined, "g").toString()).toBe("//g");
});