@@ -32,7 +32,7 @@ module RWC {
3232 } ;
3333 var baseName = / ( .* ) \/ ( .* ) .j s o n / . exec ( ts . normalizeSlashes ( jsonPath ) ) [ 2 ] ;
3434 var currentDirectory : string ;
35- var useDefaultLibFile : boolean ;
35+ var useCustomLibraryFile : boolean ;
3636
3737 after ( ( ) => {
3838 // Mocha holds onto the closure environment of the describe callback even after the test is done.
@@ -44,10 +44,10 @@ module RWC {
4444 baselineOpts = undefined ;
4545 baseName = undefined ;
4646 currentDirectory = undefined ;
47- // useDefaultLibFile is a flag specified in the json object to indicate whether to use built/local/lib.d.ts
48- // or to use lib.d.ts inside the json object. If the flag is true or undefine , use the build/local/ lib.d.ts
49- // otherwise use the lib.d.ts from the json object.
50- useDefaultLibFile = undefined ;
47+ // useCustomLibraryFile is a flag specified in the json object to indicate whether to use built/local/lib.d.ts
48+ // or to use lib.d.ts inside the json object. If the flag is true, use the lib.d.ts inside json file
49+ // otherwise use the lib.d.ts from built/local
50+ useCustomLibraryFile = undefined ;
5151 } ) ;
5252
5353 it ( 'can compile' , ( ) => {
@@ -56,10 +56,7 @@ module RWC {
5656
5757 var ioLog : IOLog = JSON . parse ( Harness . IO . readFile ( jsonPath ) ) ;
5858 currentDirectory = ioLog . currentDirectory ;
59- useDefaultLibFile = ioLog . useDefaultLibFile ;
60- if ( useDefaultLibFile === undefined ) {
61- useDefaultLibFile = true ;
62- }
59+ useCustomLibraryFile = ioLog . useCustomLibraryFile ;
6360 runWithIOLog ( ioLog , ( ) => {
6461 opts = ts . parseCommandLine ( ioLog . arguments ) ;
6562 assert . equal ( opts . errors . length , 0 ) ;
@@ -78,32 +75,33 @@ module RWC {
7875 } ) ;
7976
8077 // Add files to compilation
81- ts . forEach ( ioLog . filesRead , fileRead => {
78+ for ( let fileRead of ioLog . filesRead ) {
8279 // Check if the file is already added into the set of input files.
8380 var resolvedPath = ts . normalizeSlashes ( ts . sys . resolvePath ( fileRead . path ) ) ;
84- var inInputList = ts . forEach ( inputFiles , inputFile => inputFile . unitName === resolvedPath ) ;
81+ var inInputList = ts . forEach ( inputFiles , inputFile => inputFile . unitName === resolvedPath ) ;
8582
8683 if ( ! Harness . isLibraryFile ( fileRead . path ) ) {
87- if ( ! inInputList ) {
88- otherFiles . push ( getHarnessCompilerInputUnit ( fileRead . path ) ) ;
84+ if ( inInputList ) {
85+ continue ;
8986 }
87+ otherFiles . push ( getHarnessCompilerInputUnit ( fileRead . path ) ) ;
9088 }
9189 else if ( ! opts . options . noLib && Harness . isLibraryFile ( fileRead . path ) ) {
9290 if ( ! inInputList ) {
93- // If useDefaultLibFile is true, we will use built/local/ lib.d.ts
94- // instead of the provided lib.d.ts from json object.
91+ // If useCustomLibraryFile is true, we will use lib.d.ts from json object
92+ // otherwise use the lib.d.ts from built/local
9593 // Majority of RWC code will be using built/local/lib.d.ts instead of
9694 // lib.d.ts inside json file. However, some RWC cases will still use
9795 // their own version of lib.d.ts because they have customized lib.d.ts
98- if ( useDefaultLibFile ) {
99- inputFiles . push ( Harness . getDefaultLibraryFile ( ) ) ;
96+ if ( useCustomLibraryFile ) {
97+ inputFiles . push ( getHarnessCompilerInputUnit ( fileRead . path ) ) ;
10098 }
10199 else {
102- inputFiles . push ( getHarnessCompilerInputUnit ( fileRead . path ) ) ;
100+ inputFiles . push ( Harness . getDefaultLibraryFile ( ) ) ;
103101 }
104102 }
105103 }
106- } ) ;
104+ }
107105
108106 // do not use lib since we already read it in above
109107 opts . options . noLib = true ;
@@ -140,7 +138,10 @@ module RWC {
140138
141139 it ( 'has the expected declaration file content' , ( ) => {
142140 Harness . Baseline . runBaseline ( 'has the expected declaration file content' , baseName + '.d.ts' , ( ) => {
143- if ( ! compilerResult . declFilesCode . length ) { return null ; }
141+ if ( ! compilerResult . declFilesCode . length ) {
142+ return null ;
143+ }
144+
144145 return Harness . Compiler . collateOutputs ( compilerResult . declFilesCode ) ;
145146 } , false , baselineOpts ) ;
146147 } ) ;
0 commit comments