Formatting.

This commit is contained in:
Cyrus Najmabadi 2014-12-14 23:22:19 -08:00
parent 0ec9f0d3bb
commit 1bfe500897
2 changed files with 53 additions and 53 deletions

View file

@ -113,22 +113,22 @@ module FourSlash {
// To add additional option, add property into the testOptMetadataNames, refer the property in either globalMetadataNames or fileMetadataNames
// Add cases into convertGlobalOptionsToCompilationsSettings function for the compiler to acknowledge such option from meta data
var testOptMetadataNames = {
baselineFile: 'BaselineFile',
declaration: 'declaration',
emitThisFile: 'emitThisFile', // This flag is used for testing getEmitOutput feature. It allows test-cases to indicate what file to be output in multiple files project
filename: 'Filename',
mapRoot: 'mapRoot',
module: 'module',
out: 'out',
outDir: 'outDir',
sourceMap: 'sourceMap',
sourceRoot: 'sourceRoot',
resolveReference: 'ResolveReference', // This flag is used to specify entry file for resolve file references. The flag is only allow once per test file
baselineFile: 'BaselineFile',
declaration: 'declaration',
emitThisFile: 'emitThisFile', // This flag is used for testing getEmitOutput feature. It allows test-cases to indicate what file to be output in multiple files project
filename: 'Filename',
mapRoot: 'mapRoot',
module: 'module',
out: 'out',
outDir: 'outDir',
sourceMap: 'sourceMap',
sourceRoot: 'sourceRoot',
resolveReference: 'ResolveReference', // This flag is used to specify entry file for resolve file references. The flag is only allow once per test file
};
// List of allowed metadata names
var fileMetadataNames = [testOptMetadataNames.filename, testOptMetadataNames.emitThisFile, testOptMetadataNames.resolveReference];
var globalMetadataNames = [testOptMetadataNames.baselineFile, testOptMetadataNames.declaration,
var globalMetadataNames = [testOptMetadataNames.baselineFile, testOptMetadataNames.declaration,
testOptMetadataNames.mapRoot, testOptMetadataNames.module, testOptMetadataNames.out,
testOptMetadataNames.outDir, testOptMetadataNames.sourceMap, testOptMetadataNames.sourceRoot]
@ -147,16 +147,16 @@ module FourSlash {
case testOptMetadataNames.module:
// create appropriate external module target for CompilationSettings
switch (globalOptions[prop]) {
case "AMD":
settings.module = ts.ModuleKind.AMD;
break;
case "CommonJS":
settings.module = ts.ModuleKind.CommonJS;
break;
default:
ts.Debug.assert(globalOptions[prop] === undefined || globalOptions[prop] === "None");
settings.module = ts.ModuleKind.None;
break;
case "AMD":
settings.module = ts.ModuleKind.AMD;
break;
case "CommonJS":
settings.module = ts.ModuleKind.CommonJS;
break;
default:
ts.Debug.assert(globalOptions[prop] === undefined || globalOptions[prop] === "None");
settings.module = ts.ModuleKind.None;
break;
}
break;
case testOptMetadataNames.out:
@ -755,7 +755,7 @@ module FourSlash {
}
public verifyQuickInfoString(negative: boolean, expectedText?: string, expectedDocumentation?: string) {
[expectedText, expectedDocumentation].forEach(str => {
[expectedText, expectedDocumentation].forEach(str => {
if (str) {
this.scenarioActions.push('<ShowQuickInfo />');
this.scenarioActions.push('<VerifyQuickInfoTextContains IgnoreSpacing="true" Text="' + escapeXmlAttributeValue(str) + '" ' + (negative ? 'ExpectsFailure="true"' : '') + ' />');
@ -800,7 +800,7 @@ module FourSlash {
result = "[\n ";
}
result += JSON.stringify(part);
});
});
if (result) {
result += "\n]";
}
@ -869,8 +869,8 @@ module FourSlash {
var help = this.getActiveSignatureHelpItem();
assert.equal(
ts.displayPartsToString(help.prefixDisplayParts) +
help.parameters.map(p => ts.displayPartsToString(p.displayParts)).join(ts.displayPartsToString(help.separatorDisplayParts)) +
ts.displayPartsToString(help.prefixDisplayParts) +
help.parameters.map(p => ts.displayPartsToString(p.displayParts)).join(ts.displayPartsToString(help.separatorDisplayParts)) +
ts.displayPartsToString(help.suffixDisplayParts), expected);
}
@ -1381,24 +1381,24 @@ module FourSlash {
Utils.assertStructuralEquals(incrementalSourceFile, referenceSourceFile);
//if (this.editValidation !== IncrementalEditValidation.SyntacticOnly) {
// var compiler = new TypeScript.TypeScriptCompiler();
// for (var i = 0; i < this.testData.files.length; i++) {
// snapshot = this.languageServiceShimHost.getScriptSnapshot(this.testData.files[i].fileName);
// compiler.addFile(this.testData.files[i].fileName, TypeScript.ScriptSnapshot.fromString(snapshot.getText(0, snapshot.getLength())), ts.ByteOrderMark.None, 0, true);
// }
//if (this.editValidation !== IncrementalEditValidation.SyntacticOnly) {
// var compiler = new TypeScript.TypeScriptCompiler();
// for (var i = 0; i < this.testData.files.length; i++) {
// snapshot = this.languageServiceShimHost.getScriptSnapshot(this.testData.files[i].fileName);
// compiler.addFile(this.testData.files[i].fileName, TypeScript.ScriptSnapshot.fromString(snapshot.getText(0, snapshot.getLength())), ts.ByteOrderMark.None, 0, true);
// }
// compiler.addFile('lib.d.ts', TypeScript.ScriptSnapshot.fromString(Harness.Compiler.libTextMinimal), ts.ByteOrderMark.None, 0, true);
// compiler.addFile('lib.d.ts', TypeScript.ScriptSnapshot.fromString(Harness.Compiler.libTextMinimal), ts.ByteOrderMark.None, 0, true);
// for (var i = 0; i < this.testData.files.length; i++) {
// var refSemanticErrs = JSON.stringify(compiler.getSemanticDiagnostics(this.testData.files[i].fileName));
// var incrSemanticErrs = JSON.stringify(this.languageService.getSemanticDiagnostics(this.testData.files[i].fileName));
// for (var i = 0; i < this.testData.files.length; i++) {
// var refSemanticErrs = JSON.stringify(compiler.getSemanticDiagnostics(this.testData.files[i].fileName));
// var incrSemanticErrs = JSON.stringify(this.languageService.getSemanticDiagnostics(this.testData.files[i].fileName));
// if (incrSemanticErrs !== refSemanticErrs) {
// this.raiseError('Mismatched incremental/full semantic errors for file ' + this.testData.files[i].fileName + '\n=== Incremental errors ===\n' + incrSemanticErrs + '\n=== Full Errors ===\n' + refSemanticErrs);
// }
// }
//}
// if (incrSemanticErrs !== refSemanticErrs) {
// this.raiseError('Mismatched incremental/full semantic errors for file ' + this.testData.files[i].fileName + '\n=== Incremental errors ===\n' + incrSemanticErrs + '\n=== Full Errors ===\n' + refSemanticErrs);
// }
// }
//}
}
private fixCaretPosition() {
@ -1654,8 +1654,8 @@ module FourSlash {
private verifyClassifications(expected: { classificationType: string; text: string; textSpan?: TextSpan }[], actual: ts.ClassifiedSpan[]) {
if (actual.length !== expected.length) {
this.raiseError('verifyClassifications failed - expected total classifications to be ' + expected.length +
', but was ' + actual.length +
jsonMismatchString());
', but was ' + actual.length +
jsonMismatchString());
}
for (var i = 0; i < expected.length; i++) {
@ -1695,8 +1695,8 @@ module FourSlash {
function jsonMismatchString() {
return ts.sys.newLine +
"expected: '" + ts.sys.newLine + JSON.stringify(expected, (k,v) => v, 2) + "'" + ts.sys.newLine +
"actual: '" + ts.sys.newLine + JSON.stringify(actual, (k, v) => v, 2) + "'";
"expected: '" + ts.sys.newLine + JSON.stringify(expected,(k, v) => v, 2) + "'" + ts.sys.newLine +
"actual: '" + ts.sys.newLine + JSON.stringify(actual,(k, v) => v, 2) + "'";
}
}
@ -1708,7 +1708,7 @@ module FourSlash {
}
public verifySyntacticClassifications(expected: { classificationType: string; text: string }[]) {
var actual = this.languageService.getSyntacticClassifications(this.activeFile.fileName,
var actual = this.languageService.getSyntacticClassifications(this.activeFile.fileName,
new ts.TextSpan(0, this.activeFile.content.length));
this.verifyClassifications(expected, actual);
@ -2590,4 +2590,4 @@ module FourSlash {
fileName: fileName
};
}
}
}

View file

@ -830,7 +830,7 @@ module Harness {
writeFile,
getCanonicalFileName,
useCaseSensitiveFileNames: () => useCaseSensitiveFileNames,
getNewLine: ()=> ts.sys.newLine
getNewLine: () => ts.sys.newLine
};
}
@ -872,7 +872,7 @@ module Harness {
}
public emitAll(ioHost?: IEmitterIOHost) {
this.compileFiles(this.inputFiles, [], (result) => {
this.compileFiles(this.inputFiles, [],(result) => {
result.files.forEach(file => {
ioHost.writeFile(file.fileName, file.code, false);
});
@ -882,7 +882,7 @@ module Harness {
result.sourceMaps.forEach(file => {
ioHost.writeFile(file.fileName, file.code, false);
});
}, () => { }, this.compileOptions);
},() => { }, this.compileOptions);
}
public compileFiles(inputFiles: { unitName: string; content: string }[],
@ -1020,7 +1020,7 @@ module Harness {
break;
case 'includebuiltfile':
inputFiles.push({ unitName: setting.value, content: IO.readFile(libFolder + setting.value)});
inputFiles.push({ unitName: setting.value, content: IO.readFile(libFolder + setting.value) });
break;
default:
@ -1129,7 +1129,7 @@ module Harness {
return ts.removeFileExtension(sourceFileName) + ".d.ts";
}
});
return ts.forEach(result.declFilesCode, declFile => declFile.fileName === dTsFileName ? declFile : undefined);
}
@ -1642,4 +1642,4 @@ module Harness {
}
// TODO: not sure why Utils.evalFile isn't working with this, eventually will concat it like old compiler instead of eval
eval(Harness.tcServicesFile);
eval(Harness.tcServicesFile);