mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-02-04 21:53:42 -06:00
Fix most tslint errors in the harness
This commit is contained in:
parent
649e40b171
commit
7076e3c9dd
@ -44,7 +44,7 @@ class CompilerBaselineRunner extends RunnerBase {
|
||||
// Everything declared here should be cleared out in the "after" callback.
|
||||
var justName: string;
|
||||
var content: string;
|
||||
var testCaseContent: { settings: Harness.TestCaseParser.CompilerSetting[]; testUnitData: Harness.TestCaseParser.TestUnitData[]; }
|
||||
var testCaseContent: { settings: Harness.TestCaseParser.CompilerSetting[]; testUnitData: Harness.TestCaseParser.TestUnitData[]; };
|
||||
|
||||
var units: Harness.TestCaseParser.TestUnitData[];
|
||||
var tcSettings: Harness.TestCaseParser.CompilerSetting[];
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
//
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
//
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
@ -135,7 +135,7 @@ module FourSlash {
|
||||
var fileMetadataNames = [metadataOptionNames.fileName, metadataOptionNames.emitThisFile, metadataOptionNames.resolveReference];
|
||||
var globalMetadataNames = [metadataOptionNames.allowNonTsExtensions, metadataOptionNames.baselineFile, metadataOptionNames.declaration,
|
||||
metadataOptionNames.mapRoot, metadataOptionNames.module, metadataOptionNames.out,
|
||||
metadataOptionNames.outDir, metadataOptionNames.sourceMap, metadataOptionNames.sourceRoot]
|
||||
metadataOptionNames.outDir, metadataOptionNames.sourceMap, metadataOptionNames.sourceRoot];
|
||||
|
||||
function convertGlobalOptionsToCompilerOptions(globalOptions: { [idx: string]: string }): ts.CompilerOptions {
|
||||
var settings: ts.CompilerOptions = { target: ts.ScriptTarget.ES5 };
|
||||
@ -192,7 +192,7 @@ module FourSlash {
|
||||
|
||||
export class TestCancellationToken implements ts.HostCancellationToken {
|
||||
// 0 - cancelled
|
||||
// >0 - not cancelled
|
||||
// >0 - not cancelled
|
||||
// <0 - not cancelled and value denotes number of isCancellationRequested after which token become cancelled
|
||||
private static NotCanceled: number = -1;
|
||||
private numberOfCallsBeforeCancellation: number = TestCancellationToken.NotCanceled;
|
||||
@ -271,7 +271,7 @@ module FourSlash {
|
||||
private taoInvalidReason: string = null;
|
||||
|
||||
private inputFiles: ts.Map<string> = {}; // Map between inputFile's fileName and its content for easily looking up when resolving references
|
||||
|
||||
|
||||
// Add input file which has matched file name with the given reference-file path.
|
||||
// This is necessary when resolveReference flag is specified
|
||||
private addMatchedInputFile(referenceFilePath: string) {
|
||||
@ -426,7 +426,7 @@ module FourSlash {
|
||||
this.activeFile = fileToOpen;
|
||||
var fileName = fileToOpen.fileName.replace(Harness.IO.directoryName(fileToOpen.fileName), '').substr(1);
|
||||
this.scenarioActions.push('<OpenFile FileName="" SrcFileId="' + fileName + '" FileId="' + fileName + '" />');
|
||||
|
||||
|
||||
// Let the host know that this file is now open
|
||||
this.languageServiceAdapterHost.openFile(fileToOpen.fileName);
|
||||
}
|
||||
@ -755,7 +755,7 @@ module FourSlash {
|
||||
error += "Expected documentation: " + expectedDocumentation + " to equal: " + ts.displayPartsToString(details.documentation) + ".";
|
||||
}
|
||||
if (expectedKind) {
|
||||
error += "Expected kind: " + expectedKind + " to equal: " + filterCompletions[0].kind + "."
|
||||
error += "Expected kind: " + expectedKind + " to equal: " + filterCompletions[0].kind + ".";
|
||||
}
|
||||
this.raiseError(error);
|
||||
}
|
||||
@ -1151,6 +1151,7 @@ module FourSlash {
|
||||
var length: number;
|
||||
var prefixString = " >";
|
||||
|
||||
var pos = 0;
|
||||
var addSpanInfoString = () => {
|
||||
if (previousSpanInfo) {
|
||||
resultString += currentLine;
|
||||
@ -1163,7 +1164,7 @@ module FourSlash {
|
||||
}
|
||||
};
|
||||
|
||||
for (var pos = 0; pos < this.activeFile.content.length; pos++) {
|
||||
for (pos < this.activeFile.content.length; pos++) {
|
||||
if (pos === 0 || pos === fileLineMap[nextLine]) {
|
||||
nextLine++;
|
||||
addSpanInfoString();
|
||||
@ -1347,7 +1348,7 @@ module FourSlash {
|
||||
var offset = this.currentCaretPosition;
|
||||
var ch = "";
|
||||
|
||||
var checkCadence = (count >> 2) + 1
|
||||
var checkCadence = (count >> 2) + 1;
|
||||
|
||||
for (var i = 0; i < count; i++) {
|
||||
// Make the edit
|
||||
@ -1363,7 +1364,7 @@ module FourSlash {
|
||||
var edits = this.languageService.getFormattingEditsAfterKeystroke(this.activeFile.fileName, offset, ch, this.formatCodeOptions);
|
||||
if (edits.length) {
|
||||
offset += this.applyEdits(this.activeFile.fileName, edits, true);
|
||||
//this.checkPostEditInvariants();
|
||||
// this.checkPostEditInvariants();
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1388,7 +1389,7 @@ module FourSlash {
|
||||
|
||||
var offset = this.currentCaretPosition;
|
||||
var ch = "";
|
||||
var checkCadence = (count >> 2) + 1
|
||||
var checkCadence = (count >> 2) + 1;
|
||||
|
||||
for (var i = 0; i < count; i++) {
|
||||
offset--;
|
||||
@ -1503,8 +1504,8 @@ module FourSlash {
|
||||
}
|
||||
|
||||
private checkPostEditInvariants() {
|
||||
if (this.testType !== FourSlashTestType.Native) {
|
||||
// getSourcefile() results can not be serialized. Only perform these verifications
|
||||
if (this.testType !== FourSlashTestType.Native) {
|
||||
// getSourcefile() results can not be serialized. Only perform these verifications
|
||||
// if running against a native LS object.
|
||||
return;
|
||||
}
|
||||
@ -1883,7 +1884,7 @@ module FourSlash {
|
||||
assert.equal(
|
||||
expected.join(","),
|
||||
actual.fileNameList.map( file => {
|
||||
return file.replace(this.basePath + "/", "")
|
||||
return file.replace(this.basePath + "/", "");
|
||||
}).join(",")
|
||||
);
|
||||
}
|
||||
@ -2156,7 +2157,7 @@ module FourSlash {
|
||||
|
||||
// Get the text of the entire line the caret is currently at
|
||||
private getCurrentLineContent() {
|
||||
var text = this.getFileContent(this.activeFile.fileName)
|
||||
var text = this.getFileContent(this.activeFile.fileName);
|
||||
|
||||
var pos = this.currentCaretPosition;
|
||||
var startPos = pos, endPos = pos;
|
||||
@ -2286,7 +2287,7 @@ module FourSlash {
|
||||
}
|
||||
|
||||
public setCancelled(numberOfCalls: number): void {
|
||||
this.cancellationToken.setCancelled(numberOfCalls)
|
||||
this.cancellationToken.setCancelled(numberOfCalls);
|
||||
}
|
||||
|
||||
public resetCancelled(): void {
|
||||
|
||||
@ -46,7 +46,7 @@ class FourSlashRunner extends RunnerBase {
|
||||
if (testIndex >= 0) fn = fn.substr(testIndex);
|
||||
|
||||
if (justName && !justName.match(/fourslash\.ts$/i) && !justName.match(/\.d\.ts$/i)) {
|
||||
it(this.testSuiteName + ' test ' + justName + ' runs correctly',() => {
|
||||
it(this.testSuiteName + ' test ' + justName + ' runs correctly', () => {
|
||||
FourSlash.runFourSlashTest(this.basePath, this.testType, fn);
|
||||
});
|
||||
}
|
||||
|
||||
@ -124,7 +124,7 @@ class ProjectRunner extends RunnerBase {
|
||||
return ts.sys.resolvePath(testCase.projectRoot);
|
||||
}
|
||||
|
||||
function compileProjectFiles(moduleKind: ts.ModuleKind, getInputFiles: ()=> string[],
|
||||
function compileProjectFiles(moduleKind: ts.ModuleKind, getInputFiles: () => string[],
|
||||
getSourceFileText: (fileName: string) => string,
|
||||
writeFile: (fileName: string, data: string, writeByteOrderMark: boolean) => void): CompileProjectFilesResult {
|
||||
|
||||
@ -302,7 +302,7 @@ class ProjectRunner extends RunnerBase {
|
||||
}
|
||||
});
|
||||
|
||||
return compileProjectFiles(compilerResult.moduleKind,getInputFiles, getSourceFileText, writeFile);
|
||||
return compileProjectFiles(compilerResult.moduleKind, getInputFiles, getSourceFileText, writeFile);
|
||||
|
||||
function findOutpuDtsFile(fileName: string) {
|
||||
return ts.forEach(compilerResult.outputFiles, outputFile => outputFile.emittedFileName === fileName ? outputFile : undefined);
|
||||
@ -333,6 +333,8 @@ class ProjectRunner extends RunnerBase {
|
||||
describe('Projects tests', () => {
|
||||
describe(name, () => {
|
||||
function verifyCompilerResults(moduleKind: ts.ModuleKind) {
|
||||
var compilerResult: BatchCompileProjectTestCaseResult;
|
||||
|
||||
function getCompilerResolutionInfo() {
|
||||
var resolutionInfo: ProjectRunnerTestCaseResolutionInfo = {
|
||||
scenario: testCase.scenario,
|
||||
@ -357,8 +359,6 @@ class ProjectRunner extends RunnerBase {
|
||||
return resolutionInfo;
|
||||
}
|
||||
|
||||
var compilerResult: BatchCompileProjectTestCaseResult;
|
||||
|
||||
it(name + ": " + moduleNameToString(moduleKind) , () => {
|
||||
// Compile using node
|
||||
compilerResult = batchCompilerProjectTestCase(moduleKind);
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
//
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
//
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
@ -20,6 +20,9 @@
|
||||
/// <reference path='rwcRunner.ts' />
|
||||
/// <reference path='harness.ts' />
|
||||
|
||||
var runners: RunnerBase[] = [];
|
||||
var iterations: number = 1;
|
||||
|
||||
function runTests(runners: RunnerBase[]) {
|
||||
for (var i = iterations; i > 0; i--) {
|
||||
for (var j = 0; j < runners.length; j++) {
|
||||
@ -28,9 +31,6 @@ function runTests(runners: RunnerBase[]) {
|
||||
}
|
||||
}
|
||||
|
||||
var runners: RunnerBase[] = [];
|
||||
var iterations: number = 1;
|
||||
|
||||
// users can define tests to run in mytest.config that will override cmd line args, otherwise use cmd line args (test.config), otherwise no options
|
||||
var mytestconfig = 'mytest.config';
|
||||
var testconfig = 'test.config';
|
||||
@ -99,7 +99,7 @@ if (runners.length === 0) {
|
||||
runners.push(new FourSlashRunner(FourSlashTestType.Native));
|
||||
runners.push(new FourSlashRunner(FourSlashTestType.Shims));
|
||||
runners.push(new FourSlashRunner(FourSlashTestType.Server));
|
||||
//runners.push(new GeneratedFourslashRunner());
|
||||
// runners.push(new GeneratedFourslashRunner());
|
||||
}
|
||||
|
||||
ts.sys.newLine = '\r\n';
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
//
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
//
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
@ -143,7 +143,7 @@ module Harness.SourceMapRecoder {
|
||||
return { error: errorDecodeOfEncodedMapping, sourceMapSpan: decodeOfEncodedMapping };
|
||||
}
|
||||
|
||||
// 2. Relative sourceIndex
|
||||
// 2. Relative sourceIndex
|
||||
decodeOfEncodedMapping.sourceIndex += base64VLQFormatDecode();
|
||||
// Incorrect sourceIndex dont support this map
|
||||
if (createErrorIfCondition(decodeOfEncodedMapping.sourceIndex < 0, "Invalid sourceIndex found")) {
|
||||
@ -165,7 +165,7 @@ module Harness.SourceMapRecoder {
|
||||
return { error: errorDecodeOfEncodedMapping, sourceMapSpan: decodeOfEncodedMapping };
|
||||
}
|
||||
|
||||
// 4. Relative sourceColumn 0 based
|
||||
// 4. Relative sourceColumn 0 based
|
||||
decodeOfEncodedMapping.sourceColumn += base64VLQFormatDecode();
|
||||
// Incorrect sourceColumn dont support this map
|
||||
if (createErrorIfCondition(decodeOfEncodedMapping.sourceColumn < 1, "Invalid sourceLine found")) {
|
||||
@ -278,7 +278,7 @@ module Harness.SourceMapRecoder {
|
||||
}
|
||||
|
||||
if (spansOnSingleLine.length && spansOnSingleLine[0].sourceMapSpan.emittedLine !== sourceMapSpan.emittedLine) {
|
||||
// On different line from the one that we have been recording till now,
|
||||
// On different line from the one that we have been recording till now,
|
||||
writeRecordedSpans();
|
||||
spansOnSingleLine = [{ sourceMapSpan: sourceMapSpan, decodeErrors: decodedErrors }];
|
||||
}
|
||||
@ -329,6 +329,8 @@ module Harness.SourceMapRecoder {
|
||||
}
|
||||
|
||||
function writeRecordedSpans() {
|
||||
var markerIds: string[] = [];
|
||||
|
||||
function getMarkerId(markerIndex: number) {
|
||||
var markerId = "";
|
||||
if (spanMarkerContinues) {
|
||||
@ -416,7 +418,6 @@ module Harness.SourceMapRecoder {
|
||||
writeJsFileLines(currentJsLine);
|
||||
|
||||
// Emit markers
|
||||
var markerIds: string[] = [];
|
||||
iterateSpans(writeSourceMapMarker);
|
||||
|
||||
var jsFileText = getTextOfLine(currentJsLine, jsLineMap, jsFile.code);
|
||||
@ -455,7 +456,7 @@ module Harness.SourceMapRecoder {
|
||||
SourceMapSpanWriter.recordSourceMapSpan(decodedSourceMapping);
|
||||
}
|
||||
}
|
||||
SourceMapSpanWriter.close();// If the last spans werent emitted, emit them
|
||||
SourceMapSpanWriter.close(); // If the last spans werent emitted, emit them
|
||||
}
|
||||
sourceMapRecoder.Close();
|
||||
return sourceMapRecoder.lines.join('\r\n');
|
||||
|
||||
@ -63,7 +63,7 @@ class Test262BaselineRunner extends RunnerBase {
|
||||
|
||||
it('has the expected emitted code', () => {
|
||||
Harness.Baseline.runBaseline('has the expected emitted code', testState.filename + '.output.js', () => {
|
||||
var files = testState.compilerResult.files.filter(f=> f.fileName !== Test262BaselineRunner.helpersFilePath);
|
||||
var files = testState.compilerResult.files.filter(f => f.fileName !== Test262BaselineRunner.helpersFilePath);
|
||||
return Harness.Compiler.collateOutputs(files);
|
||||
}, false, Test262BaselineRunner.baselineOptions);
|
||||
});
|
||||
@ -84,8 +84,8 @@ class Test262BaselineRunner extends RunnerBase {
|
||||
Utils.assertInvariants(sourceFile, /*parent:*/ undefined);
|
||||
});
|
||||
|
||||
it('has the expected AST',() => {
|
||||
Harness.Baseline.runBaseline('has the expected AST', testState.filename + '.AST.txt',() => {
|
||||
it('has the expected AST', () => {
|
||||
Harness.Baseline.runBaseline('has the expected AST', testState.filename + '.AST.txt', () => {
|
||||
var sourceFile = testState.program.getSourceFile(Test262BaselineRunner.getTestFilePath(testState.filename));
|
||||
return Utils.sourceFileToJSON(sourceFile);
|
||||
}, false, Test262BaselineRunner.baselineOptions);
|
||||
@ -105,4 +105,4 @@ class Test262BaselineRunner extends RunnerBase {
|
||||
this.tests.forEach(test => this.runTest(test));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -13,7 +13,7 @@ class TypeWriterWalker {
|
||||
private checker: ts.TypeChecker;
|
||||
|
||||
constructor(private program: ts.Program, fullTypeCheck: boolean) {
|
||||
// Consider getting both the diagnostics checker and the non-diagnostics checker to verify
|
||||
// Consider getting both the diagnostics checker and the non-diagnostics checker to verify
|
||||
// they are consistent.
|
||||
this.checker = fullTypeCheck
|
||||
? program.getDiagnosticsProducingTypeChecker()
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user