2424/// <reference path='sourceMapRecorder.ts'/>
2525/// <reference path='runnerbase.ts'/>
2626
27- let Buffer : BufferConstructor = require ( 'buffer' ) . Buffer ;
27+ var Buffer : BufferConstructor = require ( 'buffer' ) . Buffer ;
2828
2929// this will work in the browser via browserify
30- let _chai : typeof chai = require ( 'chai' ) ;
31- let assert : typeof _chai . assert = _chai . assert ;
32- declare let __dirname : string ; // Node-specific
33- let global = < any > Function ( "return this" ) . call ( null ) ;
30+ var _chai : typeof chai = require ( 'chai' ) ;
31+ var assert : typeof _chai . assert = _chai . assert ;
32+ declare var __dirname : string ; // Node-specific
33+ var global = < any > Function ( "return this" ) . call ( null ) ;
3434
3535module Utils {
36- let global = < any > Function ( "return this" ) . call ( null ) ;
37-
3836 // Setup some globals based on the current environment
3937 export const enum ExecutionEnvironment {
4038 Node ,
@@ -98,8 +96,9 @@ module Utils {
9896 path = "tests/" + path ;
9997 }
10098
99+ let content = '' ;
101100 try {
102- let content = ts . sys . readFile ( Harness . userSpecifiedRoot + path ) ;
101+ content = ts . sys . readFile ( Harness . userSpecifiedRoot + path ) ;
103102 }
104103 catch ( err ) {
105104 return undefined ;
@@ -122,7 +121,7 @@ module Utils {
122121 } ) ;
123122 }
124123
125- export function assertInletiants ( node : ts . Node , parent : ts . Node ) : void {
124+ export function assertInvariants ( node : ts . Node , parent : ts . Node ) : void {
126125 if ( node ) {
127126 assert . isFalse ( node . pos < 0 , "node.pos < 0" ) ;
128127 assert . isFalse ( node . end < 0 , "node.end < 0" ) ;
@@ -136,7 +135,7 @@ module Utils {
136135 }
137136
138137 ts . forEachChild ( node , child => {
139- assertInletiants ( child , node ) ;
138+ assertInvariants ( child , node ) ;
140139 } ) ;
141140
142141 // Make sure each of the children is in order.
@@ -606,8 +605,8 @@ module Harness {
606605 export function writeToServerSync ( url : string , action : string , contents ?: string ) : XHRResponse {
607606 let xhr = new XMLHttpRequest ( ) ;
608607 try {
609- let action = '?action=' + action ;
610- xhr . open ( 'POST' , url + action , false ) ;
608+ let actionMsg = '?action=' + action ;
609+ xhr . open ( 'POST' , url + actionMsg , false ) ;
611610 xhr . setRequestHeader ( 'Access-Control-Allow-Origin' , '*' ) ;
612611 xhr . send ( contents ) ;
613612 }
@@ -645,7 +644,7 @@ module Harness {
645644 if ( dirPath . match ( / .* \/ $ / ) ) {
646645 dirPath = dirPath . substring ( 0 , dirPath . length - 2 ) ;
647646 }
648- let dirPath = dirPath . substring ( 0 , dirPath . lastIndexOf ( '/' ) ) ;
647+ dirPath = dirPath . substring ( 0 , dirPath . lastIndexOf ( '/' ) ) ;
649648 }
650649
651650 return dirPath ;
@@ -690,7 +689,7 @@ module Harness {
690689 }
691690 }
692691
693- export let IO : IO ;
692+ export var IO : IO ;
694693 switch ( Utils . getExecutionEnvironment ( ) ) {
695694 case Utils . ExecutionEnvironment . CScript :
696695 IO = IOImpl . CScript ;
@@ -808,18 +807,18 @@ module Harness {
808807 }
809808 }
810809
811- export function createSourceFileAndAssertInletiants (
810+ export function createSourceFileAndAssertInvariants (
812811 fileName : string ,
813812 sourceText : string ,
814813 languageVersion : ts . ScriptTarget ) {
815814 // We'll only assert inletiants outside of light mode.
816- const shouldAssertInletiants = ! Harness . lightMode ;
815+ const shouldassertInvariants = ! Harness . lightMode ;
817816
818817 // Only set the parent nodes if we're asserting inletiants. We don't need them otherwise.
819- let result = ts . createSourceFile ( fileName , sourceText , languageVersion , /*setParentNodes:*/ shouldAssertInletiants ) ;
818+ let result = ts . createSourceFile ( fileName , sourceText , languageVersion , /*setParentNodes:*/ shouldassertInvariants ) ;
820819
821- if ( shouldAssertInletiants ) {
822- Utils . assertInletiants ( result , /*parent:*/ undefined ) ;
820+ if ( shouldassertInvariants ) {
821+ Utils . assertInvariants ( result , /*parent:*/ undefined ) ;
823822 }
824823
825824 return result ;
@@ -829,8 +828,8 @@ module Harness {
829828 const lineFeed = "\n" ;
830829
831830 export let defaultLibFileName = 'lib.d.ts' ;
832- export let defaultLibSourceFile = createSourceFileAndAssertInletiants ( defaultLibFileName , IO . readFile ( libFolder + 'lib.core.d.ts' ) , /*languageVersion*/ ts . ScriptTarget . Latest ) ;
833- export let defaultES6LibSourceFile = createSourceFileAndAssertInletiants ( defaultLibFileName , IO . readFile ( libFolder + 'lib.core.es6.d.ts' ) , /*languageVersion*/ ts . ScriptTarget . Latest ) ;
831+ export let defaultLibSourceFile = createSourceFileAndAssertInvariants ( defaultLibFileName , IO . readFile ( libFolder + 'lib.core.d.ts' ) , /*languageVersion*/ ts . ScriptTarget . Latest ) ;
832+ export let defaultES6LibSourceFile = createSourceFileAndAssertInvariants ( defaultLibFileName , IO . readFile ( libFolder + 'lib.core.es6.d.ts' ) , /*languageVersion*/ ts . ScriptTarget . Latest ) ;
834833
835834 // Cache these between executions so we don't have to re-parse them for every test
836835 export let fourslashFileName = 'fourslash.ts' ;
@@ -861,7 +860,7 @@ module Harness {
861860 function register ( file : { unitName : string ; content : string ; } ) {
862861 if ( file . content !== undefined ) {
863862 let fileName = ts . normalizePath ( file . unitName ) ;
864- filemap [ getCanonicalFileName ( fileName ) ] = createSourceFileAndAssertInletiants ( fileName , file . content , scriptTarget ) ;
863+ filemap [ getCanonicalFileName ( fileName ) ] = createSourceFileAndAssertInvariants ( fileName , file . content , scriptTarget ) ;
865864 }
866865 } ;
867866 inputFiles . forEach ( register ) ;
@@ -884,7 +883,7 @@ module Harness {
884883 }
885884 else if ( fn === fourslashFileName ) {
886885 let tsFn = 'tests/cases/fourslash/' + fourslashFileName ;
887- fourslashSourceFile = fourslashSourceFile || createSourceFileAndAssertInletiants ( tsFn , Harness . IO . readFile ( tsFn ) , scriptTarget ) ;
886+ fourslashSourceFile = fourslashSourceFile || createSourceFileAndAssertInvariants ( tsFn , Harness . IO . readFile ( tsFn ) , scriptTarget ) ;
888887 return fourslashSourceFile ;
889888 }
890889 else {
@@ -1192,12 +1191,12 @@ module Harness {
11921191 throw new Error ( 'There were no errors and declFiles generated did not match number of js files generated' ) ;
11931192 }
11941193
1194+ let declInputFiles : { unitName : string ; content : string } [ ] = [ ] ;
1195+ let declOtherFiles : { unitName : string ; content : string } [ ] = [ ] ;
1196+ let declResult : Harness . Compiler . CompilerResult ;
1197+
11951198 // if the .d.ts is non-empty, confirm it compiles correctly as well
11961199 if ( options . declaration && result . errors . length === 0 && result . declFilesCode . length > 0 ) {
1197- let declInputFiles : { unitName : string ; content : string } [ ] = [ ] ;
1198- let declOtherFiles : { unitName : string ; content : string } [ ] = [ ] ;
1199- let declResult : Harness . Compiler . CompilerResult ;
1200-
12011200 ts . forEach ( inputFiles , file => addDtsFile ( file , declInputFiles ) ) ;
12021201 ts . forEach ( otherFiles , file => addDtsFile ( file , declOtherFiles ) ) ;
12031202 this . compileFiles ( declInputFiles , declOtherFiles , function ( compileResult ) { declResult = compileResult ; } ,
0 commit comments