@@ -3,7 +3,7 @@ import { PatternMatcher } from "../src/"
3
3
4
4
const NAMED_CAPTURE_GROUP_SUPPORTED = ( ( ) => {
5
5
try {
6
- new RegExp ( "(?<a>)" , "u" ) //eslint-disable-line no-new, @mysticatea/node/no-unsupported-features
6
+ new RegExp ( "(?<a>)" , "u" ) //eslint-disable-line no-new, @mysticatea/node/no-unsupported-features/es-syntax
7
7
return true
8
8
} catch ( _error ) {
9
9
return false
@@ -44,16 +44,16 @@ describe("The 'PatternMatcher' class:", () => {
44
44
] ) {
45
45
assert . throws (
46
46
( ) => new PatternMatcher ( value ) ,
47
- / ^ T y p e E r r o r : ' p a t t e r n ' s h o u l d b e a R e g E x p i n s t a n c e \. $ /
47
+ / ^ T y p e E r r o r : ' p a t t e r n ' s h o u l d b e a R e g E x p i n s t a n c e \. $ / u
48
48
)
49
49
}
50
50
} )
51
51
52
52
it ( "should throw Error if the RegExp value does not have 'g' flag." , ( ) => {
53
- for ( const value of [ / f o o / , / b a r / im ] ) {
53
+ for ( const value of [ / f o o / u , / b a r / imu ] ) {
54
54
assert . throws (
55
55
( ) => new PatternMatcher ( value ) ,
56
- / ^ E r r o r : ' p a t t e r n ' s h o u l d c o n t a i n s ' g ' f l a g \. $ /
56
+ / ^ E r r o r : ' p a t t e r n ' s h o u l d c o n t a i n s ' g ' f l a g \. $ / u
57
57
)
58
58
}
59
59
} )
@@ -116,7 +116,7 @@ describe("The 'PatternMatcher' class:", () => {
116
116
it ( `should return ${ JSON . stringify (
117
117
expected
118
118
) } in ${ JSON . stringify ( str ) } .`, ( ) => {
119
- const matcher = new PatternMatcher ( / f o o / g )
119
+ const matcher = new PatternMatcher ( / f o o / gu )
120
120
const actual = Array . from ( matcher . execAll ( str ) )
121
121
assert . deepStrictEqual ( actual , expected )
122
122
} )
@@ -139,14 +139,14 @@ describe("The 'PatternMatcher' class:", () => {
139
139
it ( `should return ${ JSON . stringify (
140
140
expected
141
141
) } in ${ JSON . stringify ( str ) } .`, ( ) => {
142
- const matcher = new PatternMatcher ( / ( \w ) ( \d ) / g )
142
+ const matcher = new PatternMatcher ( / ( \w ) ( \d ) / gu )
143
143
const actual = Array . from ( matcher . execAll ( str ) )
144
144
assert . deepStrictEqual ( actual , expected )
145
145
} )
146
146
}
147
147
148
148
it ( "should iterate for two strings in parallel." , ( ) => {
149
- const matcher = new PatternMatcher ( / \w / g )
149
+ const matcher = new PatternMatcher ( / \w / gu )
150
150
const expected1 = [
151
151
newRegExpExecArray ( [ "a" ] , 0 , "a--b-c" ) ,
152
152
newRegExpExecArray ( [ "b" ] , 3 , "a--b-c" ) ,
@@ -213,7 +213,7 @@ describe("The 'PatternMatcher' class:", () => {
213
213
it ( `should return ${ JSON . stringify (
214
214
expected
215
215
) } in ${ JSON . stringify ( str ) } .`, ( ) => {
216
- const matcher = new PatternMatcher ( / f o o / g , {
216
+ const matcher = new PatternMatcher ( / f o o / gu , {
217
217
escaped : true ,
218
218
} )
219
219
const actual = Array . from ( matcher . execAll ( str ) )
@@ -238,7 +238,7 @@ describe("The 'PatternMatcher' class:", () => {
238
238
{ str : String . raw `-foo\foofooabcfoo-` , expected : true } ,
239
239
] ) {
240
240
it ( `should return ${ expected } in ${ JSON . stringify ( str ) } .` , ( ) => {
241
- const matcher = new PatternMatcher ( / f o o / g )
241
+ const matcher = new PatternMatcher ( / f o o / gu )
242
242
const actual = matcher . test ( str )
243
243
assert . deepStrictEqual ( actual , expected )
244
244
} )
@@ -278,7 +278,7 @@ describe("The 'PatternMatcher' class:", () => {
278
278
{ str : "abc" , replacer : "$0" , expected : "$0$0$0" } ,
279
279
{ str : "abc" , replacer : "$1" , expected : "$1$1$1" } ,
280
280
{
281
- pattern : / a ( b ) / g ,
281
+ pattern : / a ( b ) / gu ,
282
282
str : "abc" ,
283
283
replacer : "$1" ,
284
284
expected : "bc" ,
@@ -287,14 +287,14 @@ describe("The 'PatternMatcher' class:", () => {
287
287
it ( `should return ${ expected } in ${ JSON . stringify (
288
288
str
289
289
) } and ${ JSON . stringify ( replacer ) } .`, ( ) => {
290
- const matcher = new PatternMatcher ( pattern || / [ a - c ] / g )
290
+ const matcher = new PatternMatcher ( pattern || / [ a - c ] / gu )
291
291
const actual = str . replace ( matcher , replacer )
292
292
assert . deepStrictEqual ( actual , expected )
293
293
} )
294
294
}
295
295
296
- it ( ` should pass the correct arguments to replacers.` , ( ) => {
297
- const matcher = new PatternMatcher ( / ( \w ) ( \d ) / g )
296
+ it ( " should pass the correct arguments to replacers." , ( ) => {
297
+ const matcher = new PatternMatcher ( / ( \w ) ( \d ) / gu )
298
298
const actualArgs = [ ]
299
299
const actual = "abc1d2efg" . replace ( matcher , ( ...args ) => {
300
300
actualArgs . push ( args )
0 commit comments