From a3e87c92ee247827eeae1b2710e12b245e8fcb7a Mon Sep 17 00:00:00 2001 From: Daniel Rosenwasser Date: Wed, 3 Jun 2015 17:55:55 -0700 Subject: [PATCH] Reverted back to using the 'assertInvariants' parameter. --- src/harness/harness.ts | 15 ++++++++------- src/harness/projectsRunner.ts | 2 +- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/src/harness/harness.ts b/src/harness/harness.ts index 654936c892..ca179d1e54 100644 --- a/src/harness/harness.ts +++ b/src/harness/harness.ts @@ -809,12 +809,13 @@ module Harness { } } - export function createSourceFileAndAssertInvariants(fileName: string, sourceText: string, languageVersion: ts.ScriptTarget, lightMode: boolean) { + export function createSourceFileAndAssertInvariants(fileName: string, sourceText: string, languageVersion: ts.ScriptTarget, assertInvariants: 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 (!lightMode) { + var result = ts.createSourceFile(fileName, sourceText, languageVersion, /*setParentNodes:*/ assertInvariants); + if (assertInvariants) { Utils.assertInvariants(result, /*parent:*/ undefined); } + return result; } @@ -822,8 +823,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, Harness.lightMode); - export var defaultES6LibSourceFile = createSourceFileAndAssertInvariants(defaultLibFileName, IO.readFile(libFolder + 'lib.core.es6.d.ts'), /*languageVersion*/ ts.ScriptTarget.Latest, Harness.lightMode); + export var defaultLibSourceFile = createSourceFileAndAssertInvariants(defaultLibFileName, IO.readFile(libFolder + 'lib.core.d.ts'), /*languageVersion*/ ts.ScriptTarget.Latest, /*assertInvariants*/ !Harness.lightMode); + export var defaultES6LibSourceFile = createSourceFileAndAssertInvariants(defaultLibFileName, IO.readFile(libFolder + 'lib.core.es6.d.ts'), /*languageVersion*/ ts.ScriptTarget.Latest, /*assertInvariants*/ !Harness.lightMode); // Cache these between executions so we don't have to re-parse them for every test export var fourslashFileName = 'fourslash.ts'; @@ -853,7 +854,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, Harness.lightMode); + filemap[getCanonicalFileName(fileName)] = createSourceFileAndAssertInvariants(fileName, file.content, scriptTarget, /*assertInvariants*/ !Harness.lightMode); } }; inputFiles.forEach(register); @@ -876,7 +877,7 @@ module Harness { } else if (fn === fourslashFileName) { var tsFn = 'tests/cases/fourslash/' + fourslashFileName; - fourslashSourceFile = fourslashSourceFile || createSourceFileAndAssertInvariants(tsFn, Harness.IO.readFile(tsFn), scriptTarget, Harness.lightMode); + fourslashSourceFile = fourslashSourceFile || createSourceFileAndAssertInvariants(tsFn, Harness.IO.readFile(tsFn), scriptTarget, /*assertInvariants*/ !Harness.lightMode); return fourslashSourceFile; } else { diff --git a/src/harness/projectsRunner.ts b/src/harness/projectsRunner.ts index 3ecb9a43f5..bcff2ef193 100644 --- a/src/harness/projectsRunner.ts +++ b/src/harness/projectsRunner.ts @@ -174,7 +174,7 @@ class ProjectRunner extends RunnerBase { else { var text = getSourceFileText(fileName); if (text !== undefined) { - sourceFile = Harness.Compiler.createSourceFileAndAssertInvariants(fileName, text, languageVersion, /*lightMode*/ false); + sourceFile = Harness.Compiler.createSourceFileAndAssertInvariants(fileName, text, languageVersion, /*assertInvariants*/ !Harness.lightMode); } }