24
24
/// <reference path='sourceMapRecorder.ts'/>
25
25
/// <reference path='runnerbase.ts'/>
26
26
27
- let Buffer : BufferConstructor = require ( 'buffer' ) . Buffer ;
27
+ var Buffer : BufferConstructor = require ( 'buffer' ) . Buffer ;
28
28
29
29
// 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 ) ;
34
34
35
35
module Utils {
36
- let global = < any > Function ( "return this" ) . call ( null ) ;
37
-
38
36
// Setup some globals based on the current environment
39
37
export const enum ExecutionEnvironment {
40
38
Node ,
@@ -98,8 +96,9 @@ module Utils {
98
96
path = "tests/" + path ;
99
97
}
100
98
99
+ let content = '' ;
101
100
try {
102
- let content = ts . sys . readFile ( Harness . userSpecifiedRoot + path ) ;
101
+ content = ts . sys . readFile ( Harness . userSpecifiedRoot + path ) ;
103
102
}
104
103
catch ( err ) {
105
104
return undefined ;
@@ -122,7 +121,7 @@ module Utils {
122
121
} ) ;
123
122
}
124
123
125
- export function assertInletiants ( node : ts . Node , parent : ts . Node ) : void {
124
+ export function assertInvariants ( node : ts . Node , parent : ts . Node ) : void {
126
125
if ( node ) {
127
126
assert . isFalse ( node . pos < 0 , "node.pos < 0" ) ;
128
127
assert . isFalse ( node . end < 0 , "node.end < 0" ) ;
@@ -136,7 +135,7 @@ module Utils {
136
135
}
137
136
138
137
ts . forEachChild ( node , child => {
139
- assertInletiants ( child , node ) ;
138
+ assertInvariants ( child , node ) ;
140
139
} ) ;
141
140
142
141
// Make sure each of the children is in order.
@@ -606,8 +605,8 @@ module Harness {
606
605
export function writeToServerSync ( url : string , action : string , contents ?: string ) : XHRResponse {
607
606
let xhr = new XMLHttpRequest ( ) ;
608
607
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 ) ;
611
610
xhr . setRequestHeader ( 'Access-Control-Allow-Origin' , '*' ) ;
612
611
xhr . send ( contents ) ;
613
612
}
@@ -645,7 +644,7 @@ module Harness {
645
644
if ( dirPath . match ( / .* \/ $ / ) ) {
646
645
dirPath = dirPath . substring ( 0 , dirPath . length - 2 ) ;
647
646
}
648
- let dirPath = dirPath . substring ( 0 , dirPath . lastIndexOf ( '/' ) ) ;
647
+ dirPath = dirPath . substring ( 0 , dirPath . lastIndexOf ( '/' ) ) ;
649
648
}
650
649
651
650
return dirPath ;
@@ -690,7 +689,7 @@ module Harness {
690
689
}
691
690
}
692
691
693
- export let IO : IO ;
692
+ export var IO : IO ;
694
693
switch ( Utils . getExecutionEnvironment ( ) ) {
695
694
case Utils . ExecutionEnvironment . CScript :
696
695
IO = IOImpl . CScript ;
@@ -808,18 +807,18 @@ module Harness {
808
807
}
809
808
}
810
809
811
- export function createSourceFileAndAssertInletiants (
810
+ export function createSourceFileAndAssertInvariants (
812
811
fileName : string ,
813
812
sourceText : string ,
814
813
languageVersion : ts . ScriptTarget ) {
815
814
// We'll only assert inletiants outside of light mode.
816
- const shouldAssertInletiants = ! Harness . lightMode ;
815
+ const shouldassertInvariants = ! Harness . lightMode ;
817
816
818
817
// 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 ) ;
820
819
821
- if ( shouldAssertInletiants ) {
822
- Utils . assertInletiants ( result , /*parent:*/ undefined ) ;
820
+ if ( shouldassertInvariants ) {
821
+ Utils . assertInvariants ( result , /*parent:*/ undefined ) ;
823
822
}
824
823
825
824
return result ;
@@ -829,8 +828,8 @@ module Harness {
829
828
const lineFeed = "\n" ;
830
829
831
830
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 ) ;
834
833
835
834
// Cache these between executions so we don't have to re-parse them for every test
836
835
export let fourslashFileName = 'fourslash.ts' ;
@@ -861,7 +860,7 @@ module Harness {
861
860
function register ( file : { unitName : string ; content : string ; } ) {
862
861
if ( file . content !== undefined ) {
863
862
let fileName = ts . normalizePath ( file . unitName ) ;
864
- filemap [ getCanonicalFileName ( fileName ) ] = createSourceFileAndAssertInletiants ( fileName , file . content , scriptTarget ) ;
863
+ filemap [ getCanonicalFileName ( fileName ) ] = createSourceFileAndAssertInvariants ( fileName , file . content , scriptTarget ) ;
865
864
}
866
865
} ;
867
866
inputFiles . forEach ( register ) ;
@@ -884,7 +883,7 @@ module Harness {
884
883
}
885
884
else if ( fn === fourslashFileName ) {
886
885
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 ) ;
888
887
return fourslashSourceFile ;
889
888
}
890
889
else {
@@ -1192,12 +1191,12 @@ module Harness {
1192
1191
throw new Error ( 'There were no errors and declFiles generated did not match number of js files generated' ) ;
1193
1192
}
1194
1193
1194
+ let declInputFiles : { unitName : string ; content : string } [ ] = [ ] ;
1195
+ let declOtherFiles : { unitName : string ; content : string } [ ] = [ ] ;
1196
+ let declResult : Harness . Compiler . CompilerResult ;
1197
+
1195
1198
// if the .d.ts is non-empty, confirm it compiles correctly as well
1196
1199
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
-
1201
1200
ts . forEach ( inputFiles , file => addDtsFile ( file , declInputFiles ) ) ;
1202
1201
ts . forEach ( otherFiles , file => addDtsFile ( file , declOtherFiles ) ) ;
1203
1202
this . compileFiles ( declInputFiles , declOtherFiles , function ( compileResult ) { declResult = compileResult ; } ,
0 commit comments