@@ -1007,7 +1007,7 @@ namespace FourSlash {
10071007
10081008 // If any of the expected values are undefined, assume that users don't
10091009 // care about them.
1010- if ( replacementSpan && ! TestState . textSpansEqual ( replacementSpan , entry . replacementSpan ) ) {
1010+ if ( replacementSpan && ! ts . textSpansEqual ( replacementSpan , entry . replacementSpan ) ) {
10111011 return false ;
10121012 }
10131013 else if ( expectedText && text !== expectedText ) {
@@ -1644,7 +1644,7 @@ Actual: ${stringify(fullActual)}`);
16441644 } ) ;
16451645 }
16461646
1647- public baselineGetEmitOutput ( insertResultsIntoVfs ?: boolean ) {
1647+ private getEmitFiles ( ) : ReadonlyArray < FourSlashFile > {
16481648 // Find file to be emitted
16491649 const emitFiles : FourSlashFile [ ] = [ ] ; // List of FourSlashFile that has emitThisFile flag on
16501650
@@ -1661,12 +1661,29 @@ Actual: ${stringify(fullActual)}`);
16611661 this . raiseError ( "No emitThisFile is specified in the test file" ) ;
16621662 }
16631663
1664+ return emitFiles ;
1665+ }
1666+
1667+ public verifyGetEmitOutput ( expectedOutputFiles : ReadonlyArray < string > ) : void {
1668+ const outputFiles = ts . flatMap ( this . getEmitFiles ( ) , e => this . languageService . getEmitOutput ( e . fileName ) . outputFiles ) ;
1669+
1670+ assert . deepEqual ( outputFiles . map ( f => f . name ) , expectedOutputFiles ) ;
1671+
1672+ for ( const { name, text } of outputFiles ) {
1673+ const fromTestFile = this . getFileContent ( name ) ;
1674+ if ( fromTestFile !== text ) {
1675+ this . raiseError ( "Emit output is not as expected: " + showTextDiff ( fromTestFile , text ) ) ;
1676+ }
1677+ }
1678+ }
1679+
1680+ public baselineGetEmitOutput ( ) : void {
16641681 Harness . Baseline . runBaseline (
1665- this . testData . globalOptions [ MetadataOptionNames . baselineFile ] ,
1682+ ts . Debug . assertDefined ( this . testData . globalOptions [ MetadataOptionNames . baselineFile ] ) ,
16661683 ( ) => {
16671684 let resultString = "" ;
16681685 // Loop through all the emittedFiles and emit them one by one
1669- emitFiles . forEach ( emitFile => {
1686+ for ( const emitFile of this . getEmitFiles ( ) ) {
16701687 const emitOutput = this . languageService . getEmitOutput ( emitFile . fileName ) ;
16711688 // Print emitOutputStatus in readable format
16721689 resultString += "EmitSkipped: " + emitOutput . emitSkipped + Harness . IO . newLine ( ) ;
@@ -1692,13 +1709,10 @@ Actual: ${stringify(fullActual)}`);
16921709
16931710 for ( const outputFile of emitOutput . outputFiles ) {
16941711 const fileName = "FileName : " + outputFile . name + Harness . IO . newLine ( ) ;
1695- resultString = resultString + fileName + outputFile . text ;
1696- if ( insertResultsIntoVfs ) {
1697- this . languageServiceAdapterHost . addScript ( ts . getNormalizedAbsolutePath ( outputFile . name , "/" ) , outputFile . text , /*isRootFile*/ true ) ;
1698- }
1712+ resultString = resultString + Harness . IO . newLine ( ) + fileName + outputFile . text ;
16991713 }
17001714 resultString += Harness . IO . newLine ( ) ;
1701- } ) ;
1715+ }
17021716
17031717 return resultString ;
17041718 } ) ;
@@ -2137,11 +2151,10 @@ Actual: ${stringify(fullActual)}`);
21372151 this . raiseError ( "verifyRangesInImplementationList failed - expected to find at least one implementation location but got 0" ) ;
21382152 }
21392153
2140- const duplicate = findDuplicatedElement ( implementations , implementationsAreEqual ) ;
2154+ const duplicate = findDuplicatedElement ( implementations , ts . documentSpansEqual ) ;
21412155 if ( duplicate ) {
21422156 const { textSpan, fileName } = duplicate ;
2143- const end = textSpan . start + textSpan . length ;
2144- this . raiseError ( `Duplicate implementations returned for range (${ textSpan . start } , ${ end } ) in ${ fileName } ` ) ;
2157+ this . raiseError ( `Duplicate implementations returned for range (${ textSpan . start } , ${ ts . textSpanEnd ( textSpan ) } ) in ${ fileName } ` ) ;
21452158 }
21462159
21472160 const ranges = this . getRanges ( ) ;
@@ -2208,10 +2221,6 @@ Actual: ${stringify(fullActual)}`);
22082221 this . raiseError ( error ) ;
22092222 }
22102223
2211- function implementationsAreEqual ( a : ImplementationLocationInformation , b : ImplementationLocationInformation ) {
2212- return a . fileName === b . fileName && TestState . textSpansEqual ( a . textSpan , b . textSpan ) ;
2213- }
2214-
22152224 function displayPartIsEqualTo ( a : ts . SymbolDisplayPart , b : ts . SymbolDisplayPart ) : boolean {
22162225 return a . kind === b . kind && a . text === b . text ;
22172226 }
@@ -3260,7 +3269,7 @@ Actual: ${stringify(fullActual)}`);
32603269
32613270 if ( spanIndex !== undefined ) {
32623271 const span = this . getTextSpanForRangeAtIndex ( spanIndex ) ;
3263- assert . isTrue ( TestState . textSpansEqual ( span , item . replacementSpan ) , this . assertionMessageAtLastKnownMarker ( stringify ( span ) + " does not equal " + stringify ( item . replacementSpan ) + " replacement span for " + stringify ( entryId ) ) ) ;
3272+ assert . isTrue ( ts . textSpansEqual ( span , item . replacementSpan ) , this . assertionMessageAtLastKnownMarker ( stringify ( span ) + " does not equal " + stringify ( item . replacementSpan ) + " replacement span for " + stringify ( entryId ) ) ) ;
32643273 }
32653274
32663275 eq ( item . hasAction , hasAction , "hasAction" ) ;
@@ -3346,10 +3355,6 @@ Actual: ${stringify(fullActual)}`);
33463355 this . cancellationToken . resetCancelled ( ) ;
33473356 }
33483357
3349- private static textSpansEqual ( a : ts . TextSpan | undefined , b : ts . TextSpan | undefined ) : boolean {
3350- return ! ! a && ! ! b && a . start === b . start && a . length === b . length ;
3351- }
3352-
33533358 public getEditsForFileRename ( { oldPath, newPath, newFileContents } : FourSlashInterface . GetEditsForFileRenameOptions ) : void {
33543359 const test = ( fileContents : { readonly [ fileName : string ] : string } , description : string ) : void => {
33553360 const changes = this . languageService . getEditsForFileRename ( oldPath , newPath , this . formatCodeSettings , ts . emptyOptions ) ;
@@ -3551,8 +3556,13 @@ ${code}
35513556
35523557 function getNonFileNameOptionInObject ( optionObject : { [ s : string ] : string } ) : string | undefined {
35533558 for ( const option in optionObject ) {
3554- if ( option !== MetadataOptionNames . fileName ) {
3555- return option ;
3559+ switch ( option ) {
3560+ case MetadataOptionNames . fileName :
3561+ case MetadataOptionNames . baselineFile :
3562+ case MetadataOptionNames . emitThisFile :
3563+ break ;
3564+ default :
3565+ return option ;
35563566 }
35573567 }
35583568 return undefined ;
@@ -4270,8 +4280,12 @@ namespace FourSlashInterface {
42704280 this . state . baselineCurrentFileNameOrDottedNameSpans ( ) ;
42714281 }
42724282
4273- public baselineGetEmitOutput ( insertResultsIntoVfs ?: boolean ) {
4274- this . state . baselineGetEmitOutput ( insertResultsIntoVfs ) ;
4283+ public getEmitOutput ( expectedOutputFiles : ReadonlyArray < string > ) : void {
4284+ this . state . verifyGetEmitOutput ( expectedOutputFiles ) ;
4285+ }
4286+
4287+ public baselineGetEmitOutput ( ) {
4288+ this . state . baselineGetEmitOutput ( ) ;
42754289 }
42764290
42774291 public baselineQuickInfo ( ) {
0 commit comments