forked from SerenityOS/serenity
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
LibJS: Implement RegExp.prototype.compile
This is an Annex B extension to RegExp.prototype.
- Loading branch information
1 parent
562d4e4
commit 6337eb5
Showing
5 changed files
with
51 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 17 additions & 0 deletions
17
Userland/Libraries/LibJS/Tests/builtins/RegExp/RegExp.prototype.compile.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
test("basic functionality", () => { | ||
let re = /foo/; | ||
expect(re.compile.length).toBe(2); | ||
|
||
re.compile("bar"); | ||
expect(re.test("foo")).toBeFalse(); | ||
expect(re.test("bar")).toBeTrue(); | ||
|
||
expect(re.unicode).toBeFalse(); | ||
re.compile("bar", "u"); | ||
expect(re.unicode).toBeTrue(); | ||
|
||
re.compile(/baz/g); | ||
expect(re.global).toBeTrue(); | ||
expect(re.test("bar")).toBeFalse(); | ||
expect(re.test("baz")).toBeTrue(); | ||
}); |