@@ -81,7 +81,10 @@ lines.forEach((line, index) => {
81
81
return ;
82
82
}
83
83
84
- regex = parts [ 1 ] == "SAME" ? regex : escapeQuote ( parts [ 1 ] ) ;
84
+ regex =
85
+ parts [ 1 ] == "SAME"
86
+ ? regex
87
+ : escapeQuote ( parts [ 1 ] == "NULL" ? "" : parts [ 1 ] ) ;
85
88
let str = parts [ 2 ] !== "NULL" ? escapeQuote ( parts [ 2 ] ) : "" ;
86
89
let flags = parts [ 0 ] . includes ( "i" ) ? "is" : "s" ;
87
90
@@ -90,11 +93,6 @@ lines.forEach((line, index) => {
90
93
return ;
91
94
}
92
95
93
- if ( regex == "NULL" ) {
94
- testCase += `xit("line: ${ index } - test cases for NULL regexes not supported yet", () => { });` ;
95
- return ;
96
- }
97
-
98
96
if ( regex . includes ( "\\b" ) ) {
99
97
testCase += `xit("line: ${ index } - word boundary class not supported yet!", () => { });` ;
100
98
return ;
@@ -125,26 +123,20 @@ lines.forEach((line, index) => {
125
123
return ;
126
124
}
127
125
128
- nextCase += `it("line: ${ index } - matches ${ regex } against '${
129
- str
130
- } '", () => {
126
+ nextCase += `it("line: ${ index } - matches ${ regex } against '${ str } '", () => {
131
127
` ;
132
128
if ( parts [ 3 ] == "BADBR" ) {
133
129
nextCase += ` expect(() => { let foo = new RegExp("${ regex } ") }).toThrow();` ;
134
130
} else if ( parts [ 3 ] == "NOMATCH" ) {
135
131
nextCase += ` expectNotMatch("${ regex } ", ["${ str } "]);` ;
136
132
} else {
137
- nextCase += ` const match = exec("${ regex } ", "${
138
- str
139
- } ", "${ flags } ");`;
133
+ nextCase += ` const match = exec("${ regex } ", "${ str } ", "${ flags } ");` ;
140
134
141
135
// create an expect for each capture group
142
136
const captures = parts [ 3 ] . match ( / \( ( \d { 1 , 2 } | \? ) , ( \d { 1 , 2 } | \? ) \) + / g) ;
143
137
captures . forEach ( ( capture , index ) => {
144
138
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 ] } ));` ;
148
140
} ) ;
149
141
}
150
142
0 commit comments