diff --git a/src/harness/compilerRunner.ts b/src/harness/compilerRunner.ts index 97c808ef542..b1d43302372 100644 --- a/src/harness/compilerRunner.ts +++ b/src/harness/compilerRunner.ts @@ -48,7 +48,6 @@ class CompilerBaselineRunner extends RunnerBase { let units: Harness.TestCaseParser.TestUnitData[]; let tcSettings: Harness.TestCaseParser.CompilerSetting[]; - let createNewInstance: boolean; let lastUnit: Harness.TestCaseParser.TestUnitData; let rootDir: string; diff --git a/src/harness/fourslash.ts b/src/harness/fourslash.ts index 9b5d1f0f234..06a680a2224 100644 --- a/src/harness/fourslash.ts +++ b/src/harness/fourslash.ts @@ -510,8 +510,9 @@ module FourSlash { let exists = false; let startPos = startMarker.position; + let endPos: number = undefined; if (endMarker !== undefined) { - let endPos = endMarker.position; + endPos = endMarker.position; } errors.forEach(function (error: ts.Diagnostic) { @@ -989,12 +990,12 @@ module FourSlash { ts.displayPartsToString(help.suffixDisplayParts), expected); } - public verifyCurrentParameterIsletiable(isletiable: boolean) { + public verifyCurrentParameterIsletiable(isVariable: boolean) { this.taoInvalidReason = 'verifyCurrentParameterIsletiable NYI'; let signature = this.getActiveSignatureHelpItem(); assert.isNotNull(signature); - assert.equal(isletiable, signature.isletiadic); + assert.equal(isVariable, signature.isVariadic); } public verifyCurrentParameterHelpName(name: string) { @@ -1511,7 +1512,7 @@ module FourSlash { } let incrementalSourceFile = this.languageService.getSourceFile(this.activeFile.fileName); - Utils.assertInletiants(incrementalSourceFile, /*parent:*/ undefined); + Utils.assertInvariants(incrementalSourceFile, /*parent:*/ undefined); let incrementalSyntaxDiagnostics = incrementalSourceFile.parseDiagnostics; diff --git a/src/harness/harness.ts b/src/harness/harness.ts index 163591cf230..54f9041c302 100644 --- a/src/harness/harness.ts +++ b/src/harness/harness.ts @@ -24,17 +24,15 @@ /// /// -let Buffer: BufferConstructor = require('buffer').Buffer; +var Buffer: BufferConstructor = require('buffer').Buffer; // this will work in the browser via browserify -let _chai: typeof chai = require('chai'); -let assert: typeof _chai.assert = _chai.assert; -declare let __dirname: string; // Node-specific -let global = Function("return this").call(null); +var _chai: typeof chai = require('chai'); +var assert: typeof _chai.assert = _chai.assert; +declare var __dirname: string; // Node-specific +var global = Function("return this").call(null); module Utils { - let global = Function("return this").call(null); - // Setup some globals based on the current environment export const enum ExecutionEnvironment { Node, @@ -98,8 +96,9 @@ module Utils { path = "tests/" + path; } + let content = ''; try { - let content = ts.sys.readFile(Harness.userSpecifiedRoot + path); + content = ts.sys.readFile(Harness.userSpecifiedRoot + path); } catch (err) { return undefined; @@ -122,7 +121,7 @@ module Utils { }); } - export function assertInletiants(node: ts.Node, parent: ts.Node): void { + export function assertInvariants(node: ts.Node, parent: ts.Node): void { if (node) { assert.isFalse(node.pos < 0, "node.pos < 0"); assert.isFalse(node.end < 0, "node.end < 0"); @@ -136,7 +135,7 @@ module Utils { } ts.forEachChild(node, child => { - assertInletiants(child, node); + assertInvariants(child, node); }); // Make sure each of the children is in order. @@ -606,8 +605,8 @@ module Harness { export function writeToServerSync(url: string, action: string, contents?: string): XHRResponse { let xhr = new XMLHttpRequest(); try { - let action = '?action=' + action; - xhr.open('POST', url + action, false); + let actionMsg = '?action=' + action; + xhr.open('POST', url + actionMsg, false); xhr.setRequestHeader('Access-Control-Allow-Origin', '*'); xhr.send(contents); } @@ -645,7 +644,7 @@ module Harness { if (dirPath.match(/.*\/$/)) { dirPath = dirPath.substring(0, dirPath.length - 2); } - let dirPath = dirPath.substring(0, dirPath.lastIndexOf('/')); + dirPath = dirPath.substring(0, dirPath.lastIndexOf('/')); } return dirPath; @@ -690,7 +689,7 @@ module Harness { } } - export let IO: IO; + export var IO: IO; switch (Utils.getExecutionEnvironment()) { case Utils.ExecutionEnvironment.CScript: IO = IOImpl.CScript; @@ -808,18 +807,18 @@ module Harness { } } - export function createSourceFileAndAssertInletiants( + export function createSourceFileAndAssertInvariants( fileName: string, sourceText: string, languageVersion: ts.ScriptTarget) { // We'll only assert inletiants outside of light mode. - const shouldAssertInletiants = !Harness.lightMode; + const shouldassertInvariants = !Harness.lightMode; // Only set the parent nodes if we're asserting inletiants. We don't need them otherwise. - let result = ts.createSourceFile(fileName, sourceText, languageVersion, /*setParentNodes:*/ shouldAssertInletiants); + let result = ts.createSourceFile(fileName, sourceText, languageVersion, /*setParentNodes:*/ shouldassertInvariants); - if (shouldAssertInletiants) { - Utils.assertInletiants(result, /*parent:*/ undefined); + if (shouldassertInvariants) { + Utils.assertInvariants(result, /*parent:*/ undefined); } return result; @@ -829,8 +828,8 @@ module Harness { const lineFeed = "\n"; export let defaultLibFileName = 'lib.d.ts'; - export let defaultLibSourceFile = createSourceFileAndAssertInletiants(defaultLibFileName, IO.readFile(libFolder + 'lib.core.d.ts'), /*languageVersion*/ ts.ScriptTarget.Latest); - export let defaultES6LibSourceFile = createSourceFileAndAssertInletiants(defaultLibFileName, IO.readFile(libFolder + 'lib.core.es6.d.ts'), /*languageVersion*/ ts.ScriptTarget.Latest); + export let defaultLibSourceFile = createSourceFileAndAssertInvariants(defaultLibFileName, IO.readFile(libFolder + 'lib.core.d.ts'), /*languageVersion*/ ts.ScriptTarget.Latest); + export let defaultES6LibSourceFile = createSourceFileAndAssertInvariants(defaultLibFileName, IO.readFile(libFolder + 'lib.core.es6.d.ts'), /*languageVersion*/ ts.ScriptTarget.Latest); // Cache these between executions so we don't have to re-parse them for every test export let fourslashFileName = 'fourslash.ts'; @@ -861,7 +860,7 @@ module Harness { function register(file: { unitName: string; content: string; }) { if (file.content !== undefined) { let fileName = ts.normalizePath(file.unitName); - filemap[getCanonicalFileName(fileName)] = createSourceFileAndAssertInletiants(fileName, file.content, scriptTarget); + filemap[getCanonicalFileName(fileName)] = createSourceFileAndAssertInvariants(fileName, file.content, scriptTarget); } }; inputFiles.forEach(register); @@ -884,7 +883,7 @@ module Harness { } else if (fn === fourslashFileName) { let tsFn = 'tests/cases/fourslash/' + fourslashFileName; - fourslashSourceFile = fourslashSourceFile || createSourceFileAndAssertInletiants(tsFn, Harness.IO.readFile(tsFn), scriptTarget); + fourslashSourceFile = fourslashSourceFile || createSourceFileAndAssertInvariants(tsFn, Harness.IO.readFile(tsFn), scriptTarget); return fourslashSourceFile; } else { @@ -1192,12 +1191,12 @@ module Harness { throw new Error('There were no errors and declFiles generated did not match number of js files generated'); } + let declInputFiles: { unitName: string; content: string }[] = []; + let declOtherFiles: { unitName: string; content: string }[] = []; + let declResult: Harness.Compiler.CompilerResult; + // if the .d.ts is non-empty, confirm it compiles correctly as well if (options.declaration && result.errors.length === 0 && result.declFilesCode.length > 0) { - let declInputFiles: { unitName: string; content: string }[] = []; - let declOtherFiles: { unitName: string; content: string }[] = []; - let declResult: Harness.Compiler.CompilerResult; - ts.forEach(inputFiles, file => addDtsFile(file, declInputFiles)); ts.forEach(otherFiles, file => addDtsFile(file, declOtherFiles)); this.compileFiles(declInputFiles, declOtherFiles, function (compileResult) { declResult = compileResult; }, diff --git a/src/harness/projectsRunner.ts b/src/harness/projectsRunner.ts index e6bddbdba56..5ea118aacbf 100644 --- a/src/harness/projectsRunner.ts +++ b/src/harness/projectsRunner.ts @@ -60,8 +60,9 @@ class ProjectRunner extends RunnerBase { private runProjectTestCase(testCaseFileName: string) { let testCase: ProjectRunnerTestCase; + let testFileText: string = null; try { - let testFileText = ts.sys.readFile(testCaseFileName); + testFileText = ts.sys.readFile(testCaseFileName); } catch (e) { assert(false, "Unable to open testcase file: " + testCaseFileName + ": " + e.message); @@ -175,7 +176,7 @@ class ProjectRunner extends RunnerBase { else { let text = getSourceFileText(fileName); if (text !== undefined) { - sourceFile = Harness.Compiler.createSourceFileAndAssertInletiants(fileName, text, languageVersion); + sourceFile = Harness.Compiler.createSourceFileAndAssertInvariants(fileName, text, languageVersion); } } @@ -211,8 +212,9 @@ class ProjectRunner extends RunnerBase { }; function getSourceFileText(fileName: string): string { + let text: string = undefined; try { - let text = ts.sys.readFile(ts.isRootedDiskPath(fileName) + text = ts.sys.readFile(ts.isRootedDiskPath(fileName) ? fileName : ts.normalizeSlashes(testCase.projectRoot) + "/" + ts.normalizeSlashes(fileName)); } @@ -281,13 +283,14 @@ class ProjectRunner extends RunnerBase { allInputFiles.unshift({ emittedFileName: sourceFile.fileName, code: sourceFile.text }); } else if (ts.shouldEmitToOwnFile(sourceFile, compilerResult.program.getCompilerOptions())) { + let emitOutputFilePathWithoutExtension: string = undefined; if (compilerOptions.outDir) { let sourceFilePath = ts.getNormalizedAbsolutePath(sourceFile.fileName, compilerResult.program.getCurrentDirectory()); sourceFilePath = sourceFilePath.replace(compilerResult.program.getCommonSourceDirectory(), ""); - let emitOutputFilePathWithoutExtension = ts.removeFileExtension(ts.combinePaths(compilerOptions.outDir, sourceFilePath)); + emitOutputFilePathWithoutExtension = ts.removeFileExtension(ts.combinePaths(compilerOptions.outDir, sourceFilePath)); } else { - let emitOutputFilePathWithoutExtension = ts.removeFileExtension(sourceFile.fileName); + emitOutputFilePathWithoutExtension = ts.removeFileExtension(sourceFile.fileName); } let outputDtsFileName = emitOutputFilePathWithoutExtension + ".d.ts"; diff --git a/src/harness/rwcRunner.ts b/src/harness/rwcRunner.ts index 34418569082..bbe80abc887 100644 --- a/src/harness/rwcRunner.ts +++ b/src/harness/rwcRunner.ts @@ -76,7 +76,7 @@ module RWC { // Add files to compilation for (let fileRead of ioLog.filesRead) { // Check if the file is already added into the set of input files. - let resolvedPath = ts.normalizeSlashes(ts.sys.resolvePath(fileRead.path)); + var resolvedPath = ts.normalizeSlashes(ts.sys.resolvePath(fileRead.path)); let inInputList = ts.forEach(inputFiles, inputFile => inputFile.unitName === resolvedPath); if (!Harness.isLibraryFile(fileRead.path)) { @@ -118,8 +118,9 @@ module RWC { function getHarnessCompilerInputUnit(fileName: string) { let unitName = ts.normalizeSlashes(ts.sys.resolvePath(fileName)); + let content: string = null; try { - let content = ts.sys.readFile(unitName); + content = ts.sys.readFile(unitName); } catch (e) { // Leave content undefined. diff --git a/src/harness/test262Runner.ts b/src/harness/test262Runner.ts index 9707a947994..e34e58844ac 100644 --- a/src/harness/test262Runner.ts +++ b/src/harness/test262Runner.ts @@ -81,7 +81,7 @@ class Test262BaselineRunner extends RunnerBase { it('satisfies inletiants', () => { let sourceFile = testState.program.getSourceFile(Test262BaselineRunner.getTestFilePath(testState.filename)); - Utils.assertInletiants(sourceFile, /*parent:*/ undefined); + Utils.assertInvariants(sourceFile, /*parent:*/ undefined); }); it('has the expected AST', () => {