mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-02-10 15:25:54 -06:00
Update test harness
This commit is contained in:
parent
f4e10eb738
commit
917ab0aa0a
@ -127,7 +127,7 @@ namespace Utils {
|
||||
export function memoize<T extends Function>(f: T): T {
|
||||
const cache: { [idx: string]: any } = {};
|
||||
|
||||
return <any>(function () {
|
||||
return <any>(function() {
|
||||
const key = Array.prototype.join.call(arguments);
|
||||
const cachedResult = cache[key];
|
||||
if (cachedResult) {
|
||||
@ -609,7 +609,7 @@ namespace Harness {
|
||||
export const getCurrentDirectory = () => "";
|
||||
export const args = () => <string[]>[];
|
||||
export const getExecutingFilePath = () => "";
|
||||
export const exit = (exitCode: number) => {};
|
||||
export const exit = (exitCode: number) => { };
|
||||
|
||||
export let log = (s: string) => console.log(s);
|
||||
|
||||
@ -826,7 +826,7 @@ namespace Harness {
|
||||
}
|
||||
|
||||
if (!libFileNameSourceFileMap[fileName]) {
|
||||
libFileNameSourceFileMap[fileName] = createSourceFileAndAssertInvariants(fileName, IO.readFile(libFolder + fileName), ts.ScriptTarget.Latest);
|
||||
libFileNameSourceFileMap[fileName] = createSourceFileAndAssertInvariants(fileName, IO.readFile(libFolder + fileName), ts.ScriptTarget.Latest);
|
||||
}
|
||||
return libFileNameSourceFileMap[fileName];
|
||||
}
|
||||
@ -900,6 +900,20 @@ namespace Harness {
|
||||
|
||||
|
||||
return {
|
||||
getDefaultTypeDirectiveNames: (path: string) => {
|
||||
const results: string[] = [];
|
||||
fileMap.forEachValue((key, value) => {
|
||||
const rx = /node_modules\/@types\/(\w+)/;
|
||||
const typeNameResult = rx.exec(key);
|
||||
if(typeNameResult) {
|
||||
const typeName = typeNameResult[1];
|
||||
if (results.indexOf(typeName) < 0) {
|
||||
results.push(typeName);
|
||||
}
|
||||
}
|
||||
});
|
||||
return results;
|
||||
},
|
||||
getCurrentDirectory: () => currentDirectory,
|
||||
getSourceFile,
|
||||
getDefaultLibFileName,
|
||||
@ -1441,12 +1455,12 @@ namespace Harness {
|
||||
if (currentFileName) {
|
||||
// Store result file
|
||||
const newTestFile = {
|
||||
content: currentFileContent,
|
||||
name: currentFileName,
|
||||
fileOptions: currentFileOptions,
|
||||
originalFilePath: fileName,
|
||||
references: refs
|
||||
};
|
||||
content: currentFileContent,
|
||||
name: currentFileName,
|
||||
fileOptions: currentFileOptions,
|
||||
originalFilePath: fileName,
|
||||
references: refs
|
||||
};
|
||||
testUnitData.push(newTestFile);
|
||||
|
||||
// Reset local data
|
||||
@ -1544,10 +1558,10 @@ namespace Harness {
|
||||
|
||||
function baselinePath(fileName: string, type: string, baselineFolder: string, subfolder?: string) {
|
||||
if (subfolder !== undefined) {
|
||||
return Harness.userSpecifiedRoot + baselineFolder + "/" + subfolder + "/" + type + "/" + fileName;
|
||||
return Harness.userSpecifiedRoot + baselineFolder + "/" + subfolder + "/" + type + "/" + fileName;
|
||||
}
|
||||
else {
|
||||
return Harness.userSpecifiedRoot + baselineFolder + "/" + type + "/" + fileName;
|
||||
return Harness.userSpecifiedRoot + baselineFolder + "/" + type + "/" + fileName;
|
||||
}
|
||||
}
|
||||
|
||||
@ -1616,7 +1630,7 @@ namespace Harness {
|
||||
}
|
||||
|
||||
function writeComparison(expected: string, actual: string, relativeFileName: string, actualFileName: string, descriptionForDescribe: string) {
|
||||
const encoded_actual = Utils.encodeString(actual);
|
||||
const encoded_actual = Utils.encodeString(actual);
|
||||
if (expected != encoded_actual) {
|
||||
// Overwrite & issue error
|
||||
const errMsg = "The baseline file " + relativeFileName + " has changed.";
|
||||
|
||||
@ -600,6 +600,10 @@ namespace Harness.LanguageService {
|
||||
return this.host.getCurrentDirectory();
|
||||
}
|
||||
|
||||
getDirectories(path: string): string[] {
|
||||
return [];
|
||||
}
|
||||
|
||||
readDirectory(path: string, extension?: string): string[] {
|
||||
throw new Error("Not implemented Yet.");
|
||||
}
|
||||
|
||||
10
tests/cases/conformance/typings/typingsLookup1.ts
Normal file
10
tests/cases/conformance/typings/typingsLookup1.ts
Normal file
@ -0,0 +1,10 @@
|
||||
// @noImplicitReferences: true
|
||||
|
||||
// @filename: tsconfig.json
|
||||
{ "files": "a.ts" }
|
||||
|
||||
// @filename: node_modules/@types/jquery/index.d.ts
|
||||
declare var $: { x: any };
|
||||
|
||||
// @filename: a.ts
|
||||
$.x;
|
||||
@ -46,6 +46,7 @@ module ts {
|
||||
getCurrentDirectory: (): string => {
|
||||
return "";
|
||||
},
|
||||
getDirectories: (path: string) => [],
|
||||
readDirectory: (path: string, extension?: string, exclude?: string[]): string[] => {
|
||||
throw new Error("NYI");
|
||||
},
|
||||
|
||||
@ -14,6 +14,7 @@ namespace ts.server {
|
||||
resolvePath(): string { return void 0; },
|
||||
fileExists: () => false,
|
||||
directoryExists: () => false,
|
||||
getDirectories: () => [],
|
||||
createDirectory(): void {},
|
||||
getExecutingFilePath(): string { return void 0; },
|
||||
getCurrentDirectory(): string { return void 0; },
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user