@@ -59,6 +59,10 @@ class CompilerBaselineRunner extends RunnerBase {
5959 var otherFiles : { unitName : string ; content : string } [ ] ;
6060 var harnessCompiler : Harness . Compiler . HarnessCompiler ;
6161
62+ var declToBeCompiled : { unitName : string ; content : string } [ ] = [ ] ;
63+ var declOtherFiles : { unitName : string ; content : string } [ ] = [ ] ;
64+ var declResult : Harness . Compiler . CompilerResult ;
65+
6266 var createNewInstance = false ;
6367
6468 before ( ( ) => {
@@ -227,41 +231,41 @@ class CompilerBaselineRunner extends RunnerBase {
227231 }
228232 } ) ;
229233
230- it ( 'Correct JS output for ' + fileName , ( ) => {
231- if ( ! ts . fileExtensionIs ( lastUnit . name , '. d.ts' ) && this . emit ) {
232- if ( result . files . length === 0 && result . errors . length === 0 ) {
233- throw new Error ( 'Expected at least one js file to be emitted or at least one error to be created. ' ) ;
234- }
234+ // Compile .d.ts files
235+ it ( 'Compiler generated . d.ts files for ' + fileName , ( ) => {
236+ if ( options . declaration && result . errors . length === 0 && result . declFilesCode . length !== result . files . length ) {
237+ throw new Error ( 'There were no errors and declFiles generated did not match number of js files generated ' ) ;
238+ }
235239
236- if ( options . declaration && result . errors . length === 0 && result . declFilesCode . length !== result . files . length ) {
237- throw new Error ( 'There were no errors and declFiles generated did not match number of js files generated' ) ;
240+ // if the .d.ts is non-empty, confirm it compiles correctly as well
241+ if ( options . declaration && result . errors . length === 0 && result . declFilesCode . length > 0 ) {
242+ function getDtsFile ( file : { unitName : string ; content : string } ) {
243+ if ( Harness . Compiler . isDTS ( file . unitName ) ) {
244+ return file ;
245+ }
246+ else {
247+ var declFile = ts . forEach ( result . declFilesCode ,
248+ declFile => declFile . fileName === ( file . unitName . substr ( 0 , file . unitName . length - ".ts" . length ) + ".d.ts" )
249+ ? declFile : undefined ) ;
250+ return { unitName : rootDir + Harness . Path . getFileName ( declFile . fileName ) , content : declFile . code } ;
251+ }
238252 }
239253
240- var declToBeCompiled : { unitName : string ; content : string } [ ] = [ ] ;
241- var declOtherFiles : { unitName : string ; content : string } [ ] = [ ] ;
242- var declResult : Harness . Compiler . CompilerResult ;
254+ ts . forEach ( toBeCompiled , file => { declToBeCompiled . push ( getDtsFile ( file ) ) ; } ) ;
255+ ts . forEach ( otherFiles , file => { declOtherFiles . push ( getDtsFile ( file ) ) ; } ) ;
256+ harnessCompiler . compileFiles ( declToBeCompiled , declOtherFiles , function ( compileResult ) {
257+ declResult = compileResult ;
258+ } , function ( settings ) {
259+ harnessCompiler . setCompilerSettings ( tcSettings ) ;
260+ } ) ;
261+ }
262+ } ) ;
243263
244- // if the .d.ts is non-empty, confirm it compiles correctly as well
245- if ( options . declaration && result . errors . length === 0 && result . declFilesCode . length > 0 ) {
246- function getDtsFile ( file : { unitName : string ; content : string } ) {
247- if ( Harness . Compiler . isDTS ( file . unitName ) ) {
248- return file ;
249- }
250- else {
251- var declFile = ts . forEach ( result . declFilesCode ,
252- declFile => declFile . fileName === ( file . unitName . substr ( 0 , file . unitName . length - ".ts" . length ) + ".d.ts" )
253- ? declFile : undefined ) ;
254- return { unitName : rootDir + Harness . Path . getFileName ( declFile . fileName ) , content : declFile . code } ;
255- }
256- }
257264
258- ts . forEach ( toBeCompiled , file => { declToBeCompiled . push ( getDtsFile ( file ) ) ; } ) ;
259- ts . forEach ( otherFiles , file => { declOtherFiles . push ( getDtsFile ( file ) ) ; } ) ;
260- harnessCompiler . compileFiles ( declToBeCompiled , declOtherFiles , function ( compileResult ) {
261- declResult = compileResult ;
262- } , function ( settings ) {
263- harnessCompiler . setCompilerSettings ( tcSettings ) ;
264- } ) ;
265+ it ( 'Correct JS output for ' + fileName , ( ) => {
266+ if ( ! ts . fileExtensionIs ( lastUnit . name , '.d.ts' ) && this . emit ) {
267+ if ( result . files . length === 0 && result . errors . length === 0 ) {
268+ throw new Error ( 'Expected at least one js file to be emitted or at least one error to be created.' ) ;
265269 }
266270
267271 // check js output
0 commit comments