@@ -99,20 +99,45 @@ test('character class: range [a-z]', (t) => {
9999 }
100100} ) ;
101101
102- test ( 'grouping: (ab)+ ' , ( t ) => {
102+ test ( 'quantifier: {n} (fixed) ' , ( t ) => {
103103 for ( let i = 0 ; i < 100 ; i ++ ) {
104- const val = String_random ( / ( a b ) + / , { random } ) ;
105- assert . match ( val , / ^ ( a b ) + $ / ) ;
104+ const val = String_random ( / a { 5 } / , { random } ) ;
105+ assert . match ( val , / ^ a { 5 } $ / ) ;
106+ assert . strictEqual ( val . length , 5 ) ;
106107 }
107108} ) ;
108109
109- test ( 'alternation: a|b' , ( t ) => {
110+ test ( 'throws on invalid bracket' , ( t ) => {
111+ assert . throws ( ( ) => {
112+ String_random ( '[abc' , { random } ) ;
113+ } ) ;
114+ } ) ;
115+
116+ test ( 'throws on invalid brace' , ( t ) => {
117+ assert . throws ( ( ) => {
118+ String_random ( 'a{2,' , { random } ) ;
119+ } ) ;
120+ } ) ;
121+
122+ test ( 'backreference: (a)(b)\\2\\1' , ( t ) => {
110123 for ( let i = 0 ; i < 100 ; i ++ ) {
111- const val = String_random ( / a | b / , { random } ) ;
112- assert . match ( val , / ^ a $ | ^ b $ / ) ;
124+ const val = String_random ( / ( a ) ( b ) \2\1 / , { random } ) ;
125+ assert . match ( val , / ^ a b b a $ / ) ;
113126 }
114127} ) ;
115128
129+ test ( 'throws on unsupported regexp: positive lookahead' , ( t ) => {
130+ assert . throws ( ( ) => {
131+ String_random ( / (? = f o o ) .../ , { random } ) ;
132+ } ) ;
133+ } ) ;
134+
135+ test ( 'throws on unsupported regexp: lookbehind' , ( t ) => {
136+ assert . throws ( ( ) => {
137+ String_random ( / (?< = f o o ) .../ , { random } ) ;
138+ } ) ;
139+ } ) ;
140+
116141
117142const patterns = [
118143 / ^ $ / ,
0 commit comments