@@ -1142,13 +1142,16 @@ describe('expand', () => {
11421142
11431143 it . each < [ string , RegExp ] > ( [
11441144 // From https://www.regular-expressions.info/refcharclass.html
1145- [ 'Character class subtraction' , / [ c - m - [ j - z ] ] / ] ,
1146- [ 'Character class intersection' , / [ a - i & & c - z ] / ] ,
1147- [ 'Character class nested intersection' , / [ a - i & & [ c - z ] ] / ] ,
1148- ] ) ( 'does not recognize RegEx syntax: %s %p' , ( _ : string , input : RegExp ) => {
1149- const result = expandAll ( input ) ;
1150- expect ( result ) . not . toEqual ( [ 'c' , 'd' , 'e' , 'f' , 'g' , 'h' , 'i' ] ) ;
1151- } ) ;
1145+ [ 'subtraction' , / [ c - m - [ j - z ] ] / ] ,
1146+ [ 'intersection' , / [ a - i & & c - z ] / ] ,
1147+ [ 'nested intersection' , / [ a - i & & [ c - z ] ] / ] ,
1148+ ] ) (
1149+ 'does not recognize RegEx syntax: character class %s %p' ,
1150+ ( _ : string , input : RegExp ) => {
1151+ const result = expandAll ( input ) ;
1152+ expect ( result ) . not . toEqual ( [ 'c' , 'd' , 'e' , 'f' , 'g' , 'h' , 'i' ] ) ;
1153+ }
1154+ ) ;
11521155
11531156 [
11541157 // From https://www.regular-expressions.info/posixbrackets.html#class
@@ -1177,10 +1180,10 @@ describe('expand', () => {
11771180 'V' , // vertical whitespace
11781181 ] . forEach ( ( posixClass ) => {
11791182 it . each ( [
1180- [ 'POSIX class ' , `[[:${ posixClass } :]]` ] ,
1181- [ 'negative POSIX class ' , `[[:^${ posixClass } :]]` ] ,
1183+ [ '' , `[[:${ posixClass } :]]` ] ,
1184+ [ 'negative' , `[[:^${ posixClass } :]]` ] ,
11821185 ] ) (
1183- 'does not recognize RegEx syntax: %s /%s/' ,
1186+ 'does not recognize RegEx syntax: %s POSIX class /%s/' ,
11841187 ( _ : string , input : string ) => {
11851188 const result = expandAll ( input ) ;
11861189 expect ( result . pop ( ) ) . toEqual ( ':]' ) ;
@@ -1205,12 +1208,9 @@ describe('expand', () => {
12051208 'Word' ,
12061209 'XDigit' ,
12071210 ] . forEach ( ( javaPosixClass ) => {
1208- it . each ( [
1209- [ 'Java POSIX class' , `\p{${ javaPosixClass } }` ] ,
1210- [ 'Java POSIX class' , `\p{Is${ javaPosixClass } }` ] ,
1211- ] ) (
1212- 'does not recognize RegEx syntax: %s /%s/' ,
1213- ( _ : string , input : string ) => {
1211+ it . each ( [ `\p{${ javaPosixClass } }` , `\p{Is${ javaPosixClass } }` ] ) (
1212+ `does not recognize RegEx syntax: Java ${ javaPosixClass } POSIX class /%s/` ,
1213+ ( input : string ) => {
12141214 const result = expandAll ( input ) ;
12151215 expect ( result ) . toHaveLength ( 1 ) ;
12161216 expect ( result [ 0 ] ) . toMatch ( / ^ p { / ) ;
@@ -1396,7 +1396,7 @@ describe('expand', () => {
13961396 [ '' , `\p{In${ unicodeBlock } }` ] ,
13971397 [ 'lowercase' , `\p{In${ unicodeBlock . toLowerCase ( ) } }` ] ,
13981398 ] ) (
1399- ' does not recognize RegEx syntax: Unicode block %s /%s/' ,
1399+ ` does not recognize RegEx syntax: ${ unicodeBlock } Unicode block %s /%s/` ,
14001400 testUnicodeBlock
14011401 ) ;
14021402
@@ -1406,7 +1406,7 @@ describe('expand', () => {
14061406 [ 'hyphens for underscores' , `\p{${ unicodeBlock . replace ( '_' , '-' ) } }` ] ,
14071407 [ 'spaces for underscores' , `\p{${ unicodeBlock . replace ( '_' , ' ' ) } }` ] ,
14081408 ] ) (
1409- ' does not recognize RegEx syntax: Unicode block %s /%s/' ,
1409+ ` does not recognize RegEx syntax: ${ unicodeBlock } Unicode block %s /%s/` ,
14101410 testUnicodeBlock
14111411 ) ;
14121412 }
@@ -1417,7 +1417,7 @@ describe('expand', () => {
14171417 [ 'underscores for hyphens' , `\p{${ unicodeBlock . replace ( '-' , '_' ) } }` ] ,
14181418 [ 'spaces for hyphens' , `\p{${ unicodeBlock . replace ( '-' , ' ' ) } }` ] ,
14191419 ] ) (
1420- ' does not recognize RegEx syntax: Unicode block %s /%s/' ,
1420+ ` does not recognize RegEx syntax: ${ unicodeBlock } Unicode block %s /%s/` ,
14211421 testUnicodeBlock
14221422 ) ;
14231423 }
@@ -1507,7 +1507,7 @@ describe('expand', () => {
15071507 [ 'Longhand format' , `\p{Is${ unicodeCategory } }` ] ,
15081508 [ 'Longhand negative format' , `\p{^${ unicodeCategory } }` ] ,
15091509 ] ) (
1510- ' does not recognize RegEx syntax: Unicode category %s /%s/' ,
1510+ ` does not recognize RegEx syntax: ${ unicodeCategory } Unicode category %s /%s/` ,
15111511 ( _ : string , input : string ) => {
15121512 const result = expandAll ( input ) ;
15131513 expect ( result ) . toHaveLength ( 1 ) ;
@@ -1519,7 +1519,7 @@ describe('expand', () => {
15191519 [ 'Longhand negative format' , `\P{${ unicodeCategory } }` ] ,
15201520 [ 'Longhand double negative format' , `\P{^${ unicodeCategory } }` ] ,
15211521 ] ) (
1522- ' does not recognize RegEx syntax: Unicode category %s /%s/' ,
1522+ ` does not recognize RegEx syntax: ${ unicodeCategory } Unicode category %s /%s/` ,
15231523 ( _ : string , input : string ) => {
15241524 const result = expandAll ( input ) ;
15251525 expect ( result ) . toHaveLength ( 1 ) ;
@@ -1530,18 +1530,18 @@ describe('expand', () => {
15301530
15311531 // From https://www.regular-expressions.info/unicode.html#category
15321532 [ 'L' , 'M' , 'Z' , 'S' , 'N' , 'P' , 'C' ] . forEach ( ( unicodeCategory ) => {
1533- it . each ( [ [ 'Shorthand format' , `\p${ unicodeCategory } ` ] ] ) (
1534- 'does not recognize RegEx syntax: Unicode category %s /%s/' ,
1535- ( _ : string , input : string ) => {
1533+ it . each ( [ `\p${ unicodeCategory } ` ] ) (
1534+ 'does not recognize RegEx syntax: Unicode category shorthand format /%s/' ,
1535+ ( input : string ) => {
15361536 const result = expandAll ( input ) ;
15371537 expect ( result ) . toHaveLength ( 1 ) ;
15381538 expect ( result [ 0 ] ) . toMatch ( / ^ p / ) ;
15391539 }
15401540 ) ;
15411541
1542- it . each ( [ [ 'Shorthand negative format' , `\P${ unicodeCategory } ` ] ] ) (
1543- 'does not recognize RegEx syntax: Unicode category %s /%s/' ,
1544- ( _ : string , input : string ) => {
1542+ it . each ( [ `\P${ unicodeCategory } ` ] ) (
1543+ 'does not recognize RegEx syntax: Unicode category shorthand negative format /%s/' ,
1544+ ( input : string ) => {
15451545 const result = expandAll ( input ) ;
15461546 expect ( result ) . toHaveLength ( 1 ) ;
15471547 expect ( result [ 0 ] ) . toMatch ( / ^ P / ) ;
@@ -1560,7 +1560,7 @@ describe('expand', () => {
15601560 expect ( result ) . toEqual ( [ 'X' ] ) ;
15611561 } ) ;
15621562
1563- it . each < [ string , RegExp ] > ( [
1563+ it . each < [ string , RegExp | string ] > ( [
15641564 // From https://www.regular-expressions.info/refcharacters.html
15651565 [ 'Escape sequence' , / Q a b a b E / ] ,
15661566 [ 'Octal escape sequence' , / \o { 141 } \o { 142 } \o { 141 } \o { 142 } / ] ,
@@ -1586,59 +1586,54 @@ describe('expand', () => {
15861586 // From https://www.regular-expressions.info/refadv.html
15871587 [ 'backreference in lookbehind' , / ( a b ) (?< = \1) / ] ,
15881588 [ 'marker to ignore preceeding text' , / i g n o r e t h i s \K a b a b / ] ,
1589- ] ) ( 'does not recognize RegEx syntax: %s %p' , ( _ : string , input : RegExp ) => {
1590- const result = expandAll ( input ) ;
1591- expect ( result ) . not . toEqual ( [ 'ab ab' ] ) ;
1592- } ) ;
15931589
1594- it . each ( [
15951590 // From https://www.regular-expressions.info/refext.html
15961591 [ 'numbered backreference before group' , '\\1 (ab)' ] ,
15971592 [ 'named backreference before group' , '\\k<x> (?<x>ab)' ] ,
15981593 [ 'backreference' , "(?<x>ab) \\k'x'" ] ,
15991594 [ 'backreference' , '(?<x>ab) \\k{x}' ] ,
16001595 [ 'backreference' , '(?<x>ab) \\g{x}' ] ,
16011596 [ 'failed backreference' , '(?<x>ab)? \\k<x>' ] ,
1602- ] ) (
1603- 'does not recognize RegEx syntax: %s /%s/' ,
1604- ( _ : string , input : string ) => {
1605- const result = expandAll ( input ) ;
1606- expect ( result ) . not . toEqual ( [ 'ab ab' ] ) ;
1607- }
1608- ) ;
1597+ ] ) ( 'does not recognize RegEx syntax: %s %p' , ( _ , input ) => {
1598+ const result = expandAll ( input ) ;
1599+ expect ( result ) . not . toEqual ( [ 'ab ab' ] ) ;
1600+ } ) ;
16091601
1610- it . each < [ string , RegExp ] > ( [
1602+ it . each < RegExp > ( [
16111603 // From https://www.regular-expressions.info/refrecurse.html
1612- [ 'recursion' , / a \g < 0 > ? z / ] ,
1613- [ 'recursion' , / a g ' 0 ' ? z / ] ,
1614- ] ) ( 'does not recognize RegEx syntax: %s %p' , ( _ : string , input : RegExp ) => {
1604+ / a \g < 0 > ? z / ,
1605+ / a g ' 0 ' ? z / ,
1606+ ] ) ( 'does not recognize RegEx syntax: recursion %p' , ( input : RegExp ) => {
16151607 const result = expandN ( input , 3 ) ;
16161608 expect ( result ) . not . toEqual ( [ 'az' , 'aazz' , 'aaazzz' ] ) ;
16171609 } ) ;
16181610
16191611 it . each ( [
16201612 // From https://www.regular-expressions.info/refrecurse.html
1621- [ 'subroutine call ' , 'a(b\\g<1>?y)z' ] ,
1622- [ 'subroutine call ' , "a(b\\g'1'?y)z" ] ,
1623- [ 'relative subroutine call ' , 'a(b\\g<-1>?y)z' ] ,
1624- [ 'relative subroutine call ' , "a(b\\g'-1'?y)z" ] ,
1625- [ 'named subroutine call ' , 'a(?<x>b\\g<x>?y)z' ] ,
1613+ [ '' , 'a(b\\g<1>?y)z' ] ,
1614+ [ '' , "a(b\\g'1'?y)z" ] ,
1615+ [ 'relative' , 'a(b\\g<-1>?y)z' ] ,
1616+ [ 'relative' , "a(b\\g'-1'?y)z" ] ,
1617+ [ 'named' , 'a(?<x>b\\g<x>?y)z' ] ,
16261618 ] ) (
1627- 'does not recognize RegEx syntax: %s /%s/' ,
1619+ 'does not recognize RegEx syntax: %s subroutine call /%s/' ,
16281620 ( _ : string , input : string ) => {
16291621 const result = expandN ( input , 3 ) ;
16301622 expect ( result ) . not . toEqual ( [ 'abyz' , 'abbyyz' , 'abbbyyyz' ] ) ;
16311623 }
16321624 ) ;
16331625
1634- it . each < [ string , RegExp ] > ( [
1626+ it . each < RegExp > ( [
16351627 // From https://www.regular-expressions.info/refrecurse.html
1636- [ 'forward subroutine call' , / \g < + 1 > x ( [ a b ] ) / ] ,
1637- [ 'forward subroutine call' , / \g ' + 1 ' x ( [ a b ] ) / ] ,
1638- ] ) ( 'does not recognize RegEx syntax: %s %p' , ( _ : string , input : RegExp ) => {
1639- const result = expandAll ( input ) ;
1640- expect ( result ) . not . toEqual ( [ 'axa' , 'axb' , 'bxa' , 'bxb' ] ) ;
1641- } ) ;
1628+ / \g < + 1 > x ( [ a b ] ) / ,
1629+ / \g ' + 1 ' x ( [ a b ] ) / ,
1630+ ] ) (
1631+ 'does not recognize RegEx syntax: forward subroutine call %p' ,
1632+ ( input : RegExp ) => {
1633+ const result = expandAll ( input ) ;
1634+ expect ( result ) . not . toEqual ( [ 'axa' , 'axb' , 'bxa' , 'bxb' ] ) ;
1635+ }
1636+ ) ;
16421637 } ) ;
16431638} ) ;
16441639
0 commit comments