diff options
author | Linus Groh <mail@linusgroh.de> | 2021-05-10 12:01:38 +0100 |
---|---|---|
committer | Linus Groh <mail@linusgroh.de> | 2021-05-10 12:01:38 +0100 |
commit | 60064e204984db4df2bca866b42a8bc18d8d70ae (patch) | |
tree | 24686574958571ae46c74db2fcf763059bcc7f6b /Userland/Libraries/LibJS/Tests | |
parent | c93c2dc72c8fc9c90d372c4e785c48b170543228 (diff) | |
download | serenity-60064e204984db4df2bca866b42a8bc18d8d70ae.zip |
LibJS: Make invalid RegExp flags a SyntaxError at parse time
This patch changes the validation of RegExp flags (checking for
invalid and duplicate values) from a SyntaxError at runtime to a
SyntaxError at parse time - it's not something that's supposed to be
catchable.
As a nice side effect, this simplifies the RegExpObject constructor a
bit, as it can no longer throw an exception and doesn't have to validate
the flags itself.
Diffstat (limited to 'Userland/Libraries/LibJS/Tests')
-rw-r--r-- | Userland/Libraries/LibJS/Tests/builtins/RegExp/RegExp.prototype.test.js | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/Userland/Libraries/LibJS/Tests/builtins/RegExp/RegExp.prototype.test.js b/Userland/Libraries/LibJS/Tests/builtins/RegExp/RegExp.prototype.test.js index df3e8b9771..561716a7c7 100644 --- a/Userland/Libraries/LibJS/Tests/builtins/RegExp/RegExp.prototype.test.js +++ b/Userland/Libraries/LibJS/Tests/builtins/RegExp/RegExp.prototype.test.js @@ -49,10 +49,10 @@ test("flag and options", () => { expect(re.unicode).toBe(false); expect(() => { - /foo/gg; + Function("/foo/gg"); }).toThrowWithMessage(SyntaxError, "Repeated RegExp flag 'g'"); expect(() => { - /foo/x; + Function("/foo/x"); }).toThrowWithMessage(SyntaxError, "Invalid RegExp flag 'x'"); }); |