From 6253c9b5cd6a8fa5e08bf88ddabdf0283ccf7007 Mon Sep 17 00:00:00 2001 From: Bill Ticehurst Date: Mon, 29 Feb 2016 19:21:20 -0800 Subject: [PATCH 1/3] Add JavaScriptFile to ContextFlags --- src/compiler/types.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/compiler/types.ts b/src/compiler/types.ts index 8fd21ed008a..d605a684a76 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -430,7 +430,7 @@ namespace ts { JavaScriptFile = 1 << 5, // Context flags set directly by the parser. - ParserGeneratedFlags = DisallowIn | Yield | Decorator | ThisNodeHasError | Await, + ParserGeneratedFlags = DisallowIn | Yield | Decorator | ThisNodeHasError | Await | JavaScriptFile, // Exclude these flags when parsing a Type TypeExcludesFlags = Yield | Await, From ae27b8984730879de63749023cc68d0e777f0fe6 Mon Sep 17 00:00:00 2001 From: Bill Ticehurst Date: Mon, 29 Feb 2016 22:37:42 -0800 Subject: [PATCH 2/3] Fix failing JSDocParser tests --- tests/cases/unittests/jsDocParsing.ts | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/tests/cases/unittests/jsDocParsing.ts b/tests/cases/unittests/jsDocParsing.ts index 9988383b467..e2941f7fc19 100644 --- a/tests/cases/unittests/jsDocParsing.ts +++ b/tests/cases/unittests/jsDocParsing.ts @@ -11,6 +11,9 @@ module ts { assert.isTrue(typeAndDiagnostics && typeAndDiagnostics.diagnostics.length === 0); let result = Utils.sourceFileToJSON(typeAndDiagnostics.jsDocTypeExpression.type); + + // Remove the parserContextFlags from the comparison + result = result.replace(/\,\n\s+\"parserContextFlags\": \"JavaScriptFile\"/g, ""); assert.equal(result, expected); } @@ -998,7 +1001,10 @@ module ts { ? JSON.parse(Utils.sourceFileToJSON(v)) : v; }, 4); - + + // Remove the parserContextFlags from the comparison + result = result.replace(/\,\n\s+\"parserContextFlags\": \"JavaScriptFile\"/g, ""); + if (result !== expected) { // Turn on a human-readable diff if (typeof require !== 'undefined') { From b5da80202f41e6f293153a2df945063d584b022a Mon Sep 17 00:00:00 2001 From: Bill Ticehurst Date: Tue, 1 Mar 2016 10:36:37 -0800 Subject: [PATCH 3/3] Changed how parserContextFlags are handled in tests --- src/harness/harness.ts | 4 ++++ tests/cases/unittests/jsDocParsing.ts | 5 ----- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/src/harness/harness.ts b/src/harness/harness.ts index 5c191a3b9d7..858607143d2 100644 --- a/src/harness/harness.ts +++ b/src/harness/harness.ts @@ -285,6 +285,10 @@ namespace Utils { // data we don't care about in the dump. We only care what the parser set directly // on the ast. let value = n.parserContextFlags & ts.ParserContextFlags.ParserGeneratedFlags; + + // Remove the JavaScriptFile flag, as this is just noise for JSDocParser and Test262 tests + // (which are the only tests that use this function). + value = value & ~ts.ParserContextFlags.JavaScriptFile; if (value) { o[propertyName] = getParserContextFlagName(value); } diff --git a/tests/cases/unittests/jsDocParsing.ts b/tests/cases/unittests/jsDocParsing.ts index e2941f7fc19..9c68cea3297 100644 --- a/tests/cases/unittests/jsDocParsing.ts +++ b/tests/cases/unittests/jsDocParsing.ts @@ -12,8 +12,6 @@ module ts { let result = Utils.sourceFileToJSON(typeAndDiagnostics.jsDocTypeExpression.type); - // Remove the parserContextFlags from the comparison - result = result.replace(/\,\n\s+\"parserContextFlags\": \"JavaScriptFile\"/g, ""); assert.equal(result, expected); } @@ -1002,9 +1000,6 @@ module ts { : v; }, 4); - // Remove the parserContextFlags from the comparison - result = result.replace(/\,\n\s+\"parserContextFlags\": \"JavaScriptFile\"/g, ""); - if (result !== expected) { // Turn on a human-readable diff if (typeof require !== 'undefined') {