@@ -3069,7 +3069,7 @@ export class TestState {
3069
3069
private verifyFileContent ( fileName : string , text : string ) {
3070
3070
const actual = this . getFileContent ( fileName ) ;
3071
3071
if ( actual !== text ) {
3072
- throw new Error ( `verifyFileContent failed:\n${ showTextDiff ( text , actual ) } ` ) ;
3072
+ throw new Error ( `verifyFileContent in file ' ${ fileName } ' failed:\n${ showTextDiff ( text , actual ) } ` ) ;
3073
3073
}
3074
3074
}
3075
3075
@@ -3404,10 +3404,11 @@ export class TestState {
3404
3404
return ts . first ( ranges ) ;
3405
3405
}
3406
3406
3407
- private verifyTextMatches ( actualText : string , includeWhitespace : boolean , expectedText : string ) {
3407
+ private verifyTextMatches ( actualText : string , includeWhitespace : boolean , expectedText : string , fileName ?: string ) {
3408
3408
const removeWhitespace = ( s : string ) : string => includeWhitespace ? s : this . removeWhitespace ( s ) ;
3409
3409
if ( removeWhitespace ( actualText ) !== removeWhitespace ( expectedText ) ) {
3410
- this . raiseError ( `Actual range text doesn't match expected text.\n${ showTextDiff ( expectedText , actualText ) } ` ) ;
3410
+ const addFileName = fileName ? ` in file '${ fileName } '` : "" ;
3411
+ this . raiseError ( `Actual range text${ addFileName } doesn't match expected text.\n${ showTextDiff ( expectedText , actualText ) } ` ) ;
3411
3412
}
3412
3413
}
3413
3414
@@ -3485,7 +3486,7 @@ export class TestState {
3485
3486
const newText = ts . textChanges . applyChanges ( this . getFileContent ( this . activeFile . fileName ) , change . textChanges ) ;
3486
3487
const newRange = updateTextRangeForTextChanges ( this . getOnlyRange ( this . activeFile . fileName ) , change . textChanges ) ;
3487
3488
const actualText = newText . slice ( newRange . pos , newRange . end ) ;
3488
- this . verifyTextMatches ( actualText , /*includeWhitespace*/ true , newRangeContent ) ;
3489
+ this . verifyTextMatches ( actualText , /*includeWhitespace*/ true , newRangeContent , change . fileName ) ;
3489
3490
}
3490
3491
else {
3491
3492
if ( newFileContent === undefined ) throw ts . Debug . fail ( ) ;
@@ -3497,7 +3498,7 @@ export class TestState {
3497
3498
}
3498
3499
const oldText = this . tryGetFileContent ( change . fileName ) ;
3499
3500
const newContent = change . isNewFile ? ts . first ( change . textChanges ) . newText : ts . textChanges . applyChanges ( oldText ! , change . textChanges ) ;
3500
- this . verifyTextMatches ( newContent , /*includeWhitespace*/ true , expectedNewContent ) ;
3501
+ this . verifyTextMatches ( newContent , /*includeWhitespace*/ true , expectedNewContent , change . fileName ) ;
3501
3502
}
3502
3503
for ( const newFileName in newFileContent ) {
3503
3504
ts . Debug . assert ( changes . some ( c => c . fileName === newFileName ) , "No change in file" , ( ) => newFileName ) ;
0 commit comments