mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-02-16 15:44:16 -06:00
The caller can now specify whether to observe light mode in 'createSourceFileAndAssertInvariants'.
This commit is contained in:
parent
fa50177c5d
commit
89fa211d9e
@ -797,10 +797,10 @@ module Harness {
|
||||
}
|
||||
}
|
||||
|
||||
export function createSourceFileAndAssertInvariants(fileName: string, sourceText: string, languageVersion: ts.ScriptTarget) {
|
||||
export function createSourceFileAndAssertInvariants(fileName: string, sourceText: string, languageVersion: ts.ScriptTarget, lightMode: boolean) {
|
||||
// Only set the parent nodes if we're asserting invariants. We don't need them otherwise.
|
||||
var result = ts.createSourceFile(fileName, sourceText, languageVersion, /*setParentNodes:*/ true);
|
||||
if (!Harness.lightMode) {
|
||||
if (!lightMode) {
|
||||
Utils.assertInvariants(result, /*parent:*/ undefined);
|
||||
}
|
||||
return result;
|
||||
@ -810,8 +810,8 @@ module Harness {
|
||||
const lineFeed = "\n";
|
||||
|
||||
export var defaultLibFileName = 'lib.d.ts';
|
||||
export var defaultLibSourceFile = createSourceFileAndAssertInvariants(defaultLibFileName, IO.readFile(libFolder + 'lib.core.d.ts'), /*languageVersion*/ ts.ScriptTarget.Latest);
|
||||
export var defaultES6LibSourceFile = createSourceFileAndAssertInvariants(defaultLibFileName, IO.readFile(libFolder + 'lib.core.es6.d.ts'), /*languageVersion*/ ts.ScriptTarget.Latest);
|
||||
export var defaultLibSourceFile = createSourceFileAndAssertInvariants(defaultLibFileName, IO.readFile(libFolder + 'lib.core.d.ts'), /*languageVersion*/ ts.ScriptTarget.Latest, Harness.lightMode);
|
||||
export var defaultES6LibSourceFile = createSourceFileAndAssertInvariants(defaultLibFileName, IO.readFile(libFolder + 'lib.core.es6.d.ts'), /*languageVersion*/ ts.ScriptTarget.Latest, Harness.lightMode);
|
||||
|
||||
// Cache these between executions so we don't have to re-parse them for every test
|
||||
export var fourslashFileName = 'fourslash.ts';
|
||||
@ -841,7 +841,7 @@ module Harness {
|
||||
function register(file: { unitName: string; content: string; }) {
|
||||
if (file.content !== undefined) {
|
||||
var fileName = ts.normalizePath(file.unitName);
|
||||
filemap[getCanonicalFileName(fileName)] = createSourceFileAndAssertInvariants(fileName, file.content, scriptTarget);
|
||||
filemap[getCanonicalFileName(fileName)] = createSourceFileAndAssertInvariants(fileName, file.content, scriptTarget, Harness.lightMode);
|
||||
}
|
||||
};
|
||||
inputFiles.forEach(register);
|
||||
@ -864,7 +864,7 @@ module Harness {
|
||||
}
|
||||
else if (fn === fourslashFileName) {
|
||||
var tsFn = 'tests/cases/fourslash/' + fourslashFileName;
|
||||
fourslashSourceFile = fourslashSourceFile || createSourceFileAndAssertInvariants(tsFn, Harness.IO.readFile(tsFn), scriptTarget);
|
||||
fourslashSourceFile = fourslashSourceFile || createSourceFileAndAssertInvariants(tsFn, Harness.IO.readFile(tsFn), scriptTarget, Harness.lightMode);
|
||||
return fourslashSourceFile;
|
||||
}
|
||||
else {
|
||||
|
||||
@ -174,7 +174,7 @@ class ProjectRunner extends RunnerBase {
|
||||
else {
|
||||
var text = getSourceFileText(fileName);
|
||||
if (text !== undefined) {
|
||||
sourceFile = Harness.Compiler.createSourceFileAndAssertInvariants(fileName, text, languageVersion);
|
||||
sourceFile = Harness.Compiler.createSourceFileAndAssertInvariants(fileName, text, languageVersion, /*lightMode*/ false);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user