File tree Expand file tree Collapse file tree 3 files changed +26
-1
lines changed Expand file tree Collapse file tree 3 files changed +26
-1
lines changed Original file line number Diff line number Diff line change 2
2
3
3
## Unreleased
4
4
5
+ - Fixed a bug on target JavaScript where ` regex.check ` would not correctly execute
6
+ while using the same regular expression in consecutive calls.
5
7
- The ` zip ` function's second argument in the ` list ` module gains the ` with ` label.
6
8
- The ` strict_zip ` function's second argument in the ` list ` module gains the ` with ` label.
7
9
Original file line number Diff line number Diff line change @@ -371,6 +371,7 @@ export function utf_codepoint_to_int(utf_codepoint) {
371
371
}
372
372
373
373
export function regex_check ( regex , string ) {
374
+ regex . lastIndex = 0 ;
374
375
return regex . test ( string ) ;
375
376
}
376
377
Original file line number Diff line number Diff line change @@ -27,7 +27,7 @@ pub fn compile_test() {
27
27
regex . check ( re , "abc\n 123" )
28
28
|> should . be_true
29
29
30
- // For Erlang: This test will only passes if unicode and ucp flags are set
30
+ // On target Erlang this test will only pass if unicode and ucp flags are set
31
31
let assert Ok ( re ) = regex . compile ( "\\ s" , options )
32
32
// Em space == U+2003 == " " == used below
33
33
regex . check ( re , " " )
@@ -42,6 +42,28 @@ pub fn check_test() {
42
42
43
43
regex . check ( re , "boo" )
44
44
|> should . be_false
45
+
46
+ re
47
+ |> regex . check ( content : "foo" )
48
+ |> should . be_true
49
+
50
+ "boo"
51
+ |> regex . check ( with : re )
52
+ |> should . be_false
53
+
54
+ // On target JavaScript internal `RegExp` objects are stateful when they
55
+ // have the global or sticky flags set (e.g., /foo/g or /foo/y).
56
+ // These following tests make sure that our implementation circumvents this.
57
+ let assert Ok ( re ) = regex . from_string ( "^-*[0-9]+" )
58
+
59
+ regex . check ( re , "1" )
60
+ |> should . be_true
61
+
62
+ regex . check ( re , "12" )
63
+ |> should . be_true
64
+
65
+ regex . check ( re , "123" )
66
+ |> should . be_true
45
67
}
46
68
47
69
pub fn split_test ( ) {
You can’t perform that action at this time.
0 commit comments