File tree Expand file tree Collapse file tree 1 file changed +16
-3
lines changed
Expand file tree Collapse file tree 1 file changed +16
-3
lines changed Original file line number Diff line number Diff line change @@ -146,20 +146,33 @@ function toLineContext(file: string, index: number) {
146146
147147export function fileTests ( file : string , fileName : string , mayIgnore = defaultIgnore ) {
148148 let caseExpr = / \s * # \s * ( .* ) (?: \r \n | \r | \n ) ( [ ^ ] * ?) = = + > ( [ ^ ] * ?) (?: $ | (?: \r \n | \r | \n ) + (? = # ) ) / gy
149- let tests : { name : string , run ( parser : Parser ) : void } [ ] = [ ]
149+ let tests : {
150+ name : string ,
151+ text : string ,
152+ expected : string ,
153+ configStr : string ,
154+ config : object ,
155+ strict : boolean ,
156+ run ( parser : Parser ) : void
157+ } [ ] = [ ]
150158 let lastIndex = 0 ;
151159 for ( ; ; ) {
152160 let m = caseExpr . exec ( file )
153161 if ( ! m ) throw new Error ( `Unexpected file format in ${ fileName } around\n\n${ toLineContext ( file , lastIndex ) } ` )
154162
163+ let text = m [ 2 ] . trim ( ) , expected = m [ 3 ] . trim ( )
155164 let [ , name , configStr ] = / ( .* ?) ( \{ .* ?\} ) ? $ / . exec ( m [ 1 ] ) !
156165 let config = configStr ? JSON . parse ( configStr ) : null
166+ let strict = ! / ⚠ | \. \. \. / . test ( expected )
157167
158- let text = m [ 2 ] . trim ( ) , expected = m [ 3 ]
159168 tests . push ( {
160169 name,
170+ text,
171+ expected,
172+ configStr,
173+ config,
174+ strict,
161175 run ( parser : Parser ) {
162- let strict = ! / ⚠ | \. \. \. / . test ( expected )
163176 if ( ( parser as any ) . configure && ( strict || config ) )
164177 parser = ( parser as any ) . configure ( { strict, ...config } )
165178 testTree ( parser . parse ( text ) , expected , mayIgnore )
You can’t perform that action at this time.
0 commit comments