@@ -81,7 +81,10 @@ lines.forEach((line, index) => {
8181 return ;
8282 }
8383
84- regex = parts [ 1 ] == "SAME" ? regex : escapeQuote ( parts [ 1 ] ) ;
84+ regex =
85+ parts [ 1 ] == "SAME"
86+ ? regex
87+ : escapeQuote ( parts [ 1 ] == "NULL" ? "" : parts [ 1 ] ) ;
8588 let str = parts [ 2 ] !== "NULL" ? escapeQuote ( parts [ 2 ] ) : "" ;
8689 let flags = parts [ 0 ] . includes ( "i" ) ? "is" : "s" ;
8790
@@ -90,11 +93,6 @@ lines.forEach((line, index) => {
9093 return ;
9194 }
9295
93- if ( regex == "NULL" ) {
94- testCase += `xit("line: ${ index } - test cases for NULL regexes not supported yet", () => { });` ;
95- return ;
96- }
97-
9896 if ( regex . includes ( "\\b" ) ) {
9997 testCase += `xit("line: ${ index } - word boundary class not supported yet!", () => { });` ;
10098 return ;
@@ -125,26 +123,20 @@ lines.forEach((line, index) => {
125123 return ;
126124 }
127125
128- nextCase += `it("line: ${ index } - matches ${ regex } against '${
129- str
130- } '", () => {
126+ nextCase += `it("line: ${ index } - matches ${ regex } against '${ str } '", () => {
131127 ` ;
132128 if ( parts [ 3 ] == "BADBR" ) {
133129 nextCase += ` expect(() => { let foo = new RegExp("${ regex } ") }).toThrow();` ;
134130 } else if ( parts [ 3 ] == "NOMATCH" ) {
135131 nextCase += ` expectNotMatch("${ regex } ", ["${ str } "]);` ;
136132 } else {
137- nextCase += ` const match = exec("${ regex } ", "${
138- str
139- } ", "${ flags } ");`;
133+ nextCase += ` const match = exec("${ regex } ", "${ str } ", "${ flags } ");` ;
140134
141135 // create an expect for each capture group
142136 const captures = parts [ 3 ] . match ( / \( ( \d { 1 , 2 } | \? ) , ( \d { 1 , 2 } | \? ) \) + / g) ;
143137 captures . forEach ( ( capture , index ) => {
144138 const digits = capture . match ( / \( ( \d { 1 , 2 } | \? ) , ( \d { 1 , 2 } | \? ) \) / ) ;
145- nextCase += `expect(match.matches[${ index } ]).toBe("${
146- str
147- } ".substring(${ digits [ 1 ] } , ${ digits [ 2 ] } ));`;
139+ nextCase += `expect(match.matches[${ index } ]).toBe("${ str } ".substring(${ digits [ 1 ] } , ${ digits [ 2 ] } ));` ;
148140 } ) ;
149141 }
150142
0 commit comments