From 7d13c29c45f6ab519550306927cf1866a7c6f273 Mon Sep 17 00:00:00 2001 From: Orta Date: Mon, 29 Jun 2020 15:51:20 -0400 Subject: [PATCH] Gets the tests green --- src/harness/fourslashImpl.ts | 6 ++-- .../semanticClassificationClassExpression.ts | 14 +++++----- ...stantiatedModuleWithVariableOfSameName1.ts | 4 +-- ...stantiatedModuleWithVariableOfSameName2.ts | 25 ++++++++--------- .../semanticClassificationWithUnionTypes.ts | 28 +++++++++---------- .../syntacticClassificationsForOfKeyword.ts | 10 +++---- .../syntacticClassificationsForOfKeyword2.ts | 4 +-- .../syntacticClassificationsForOfKeyword3.ts | 10 +++---- 8 files changed, 50 insertions(+), 51 deletions(-) diff --git a/src/harness/fourslashImpl.ts b/src/harness/fourslashImpl.ts index bc9927436d994..511a03c69a0a5 100644 --- a/src/harness/fourslashImpl.ts +++ b/src/harness/fourslashImpl.ts @@ -2497,15 +2497,15 @@ namespace FourSlash { jsonMismatchString()); } - ts.zipWith(expected, actual, (expectedClassification, actualClassification) => { + ts.zipWith(expected, actual, (expectedClassification, actualClassification, index) => { const expectedType = expectedClassification.classificationType; const actualType = typeof actualClassification.classificationType === "number" ? this.classificationToIdentifier(actualClassification.classificationType) : actualClassification.classificationType; if (expectedType !== actualType) { - this.raiseError("verifyClassifications failed - expected classifications type to be " + + this.raiseError(`verifyClassifications failed - expected classifications at index ${index} type to be ` + expectedType + ", but was " + actualType + - jsonMismatchString()); + displayExpectedAndActualString(JSON.stringify(expectedType, undefined, 4), JSON.stringify(actualType, undefined, 5))); } const expectedSpan = expectedClassification.textSpan; diff --git a/tests/cases/fourslash/semanticClassificationClassExpression.ts b/tests/cases/fourslash/semanticClassificationClassExpression.ts index eda79ce8f3d39..6616f61beb0b0 100644 --- a/tests/cases/fourslash/semanticClassificationClassExpression.ts +++ b/tests/cases/fourslash/semanticClassificationClassExpression.ts @@ -11,11 +11,11 @@ verify.semanticClassificationsAre("original", c.className("B", test.marker("3").position) ); -const c2 = classification("2020"); -verify.semanticClassificationsAre("2020", - c2.semanticToken("class.declaration", "x"), - c2.semanticToken("class", "C"), - c2.semanticToken("class.declaration", "C"), - c2.semanticToken("class.declaration", "D"), - c2.semanticToken("class", "B"), +const c2 = classification("2020"); +verify.semanticClassificationsAre("2020", + c2.semanticToken("class.declaration", "x"), + c2.semanticToken("class.declaration", "C"), + c2.semanticToken("class.declaration", "C"), + c2.semanticToken("class.declaration", "D"), + c2.semanticToken("class.declaration", "B"), ); diff --git a/tests/cases/fourslash/semanticClassificationUninstantiatedModuleWithVariableOfSameName1.ts b/tests/cases/fourslash/semanticClassificationUninstantiatedModuleWithVariableOfSameName1.ts index 6c1e24e2d94f0..6a495a279bf5f 100644 --- a/tests/cases/fourslash/semanticClassificationUninstantiatedModuleWithVariableOfSameName1.ts +++ b/tests/cases/fourslash/semanticClassificationUninstantiatedModuleWithVariableOfSameName1.ts @@ -13,11 +13,11 @@ verify.semanticClassificationsAre("original", c.moduleName("M", test.marker("0").position), c.interfaceName("I", test.marker("1").position)); + const c2 = classification("2020"); verify.semanticClassificationsAre("2020", - c2.semanticToken("variable", "M"), + c2.semanticToken("namespace.declaration", "M"), c2.semanticToken("interface.declaration", "I"), c2.semanticToken("variable.declaration", "M"), c2.semanticToken("property.declaration", "I"), ); - \ No newline at end of file diff --git a/tests/cases/fourslash/semanticClassificationUninstantiatedModuleWithVariableOfSameName2.ts b/tests/cases/fourslash/semanticClassificationUninstantiatedModuleWithVariableOfSameName2.ts index 1566d333c4e37..9d45176096a4f 100644 --- a/tests/cases/fourslash/semanticClassificationUninstantiatedModuleWithVariableOfSameName2.ts +++ b/tests/cases/fourslash/semanticClassificationUninstantiatedModuleWithVariableOfSameName2.ts @@ -21,17 +21,16 @@ verify.semanticClassificationsAre("original", c.moduleName("M", test.marker("3").position), c.interfaceName("I", test.marker("4").position)); -const c2 = classification("2020"); -verify.semanticClassificationsAre("2020", - c2.semanticToken("variable", "M"), - c2.semanticToken("interface.declaration", "I"), - c2.semanticToken("variable.declaration", "M"), - c2.semanticToken("property.declaration", "foo"), - c2.semanticToken("property.declaration", "bar"), - c2.semanticToken("variable.declaration", "v"), - c2.semanticToken("variable", "M"), - c2.semanticToken("interface", "I"), - c2.semanticToken("variable.declaration", "x"), - c2.semanticToken("variable", "M"), +const c2 = classification("2020"); +verify.semanticClassificationsAre("2020", + c2.semanticToken("namespace.declaration", "M"), + c2.semanticToken("interface.declaration", "I"), + c2.semanticToken("variable.declaration", "M"), + c2.semanticToken("property.declaration", "foo"), + c2.semanticToken("property.declaration", "bar"), + c2.semanticToken("variable.declaration", "v"), + c2.semanticToken("variable", "M"), + c2.semanticToken("interface", "I"), + c2.semanticToken("variable.declaration", "x"), + c2.semanticToken("variable", "M"), ); - \ No newline at end of file diff --git a/tests/cases/fourslash/semanticClassificationWithUnionTypes.ts b/tests/cases/fourslash/semanticClassificationWithUnionTypes.ts index 257130392df1f..a56a0ce888431 100644 --- a/tests/cases/fourslash/semanticClassificationWithUnionTypes.ts +++ b/tests/cases/fourslash/semanticClassificationWithUnionTypes.ts @@ -23,18 +23,18 @@ verify.semanticClassificationsAre("original", c.className("C", test.marker("7").position), c.className("C", test.marker("8").position)); -const c2 = classification("2020"); -verify.semanticClassificationsAre("2020", - c2.semanticToken("variable", "M"), - c2.semanticToken("interface.declaration", "I"), - c2.semanticToken("interface.declaration", "I"), - c2.semanticToken("class.declaration", "C"), - c2.semanticToken("variable.declaration", "M"), - c2.semanticToken("variable", "M"), - c2.semanticToken("interface", "I"), - c2.semanticToken("interface", "I"), - c2.semanticToken("class", "C"), - c2.semanticToken("class.declaration", "I"), - c2.semanticToken("variable", "M"), - c2.semanticToken("class", "C"), +const c2 = classification("2020"); +verify.semanticClassificationsAre("2020", + c2.semanticToken("namespace.declaration", "M"), + c2.semanticToken("interface.declaration", "I"), + c2.semanticToken("interface.declaration", "I"), + c2.semanticToken("class.declaration", "C"), + c2.semanticToken("variable.declaration", "M"), + c2.semanticToken("variable", "M"), + c2.semanticToken("interface", "I"), + c2.semanticToken("interface", "I"), + c2.semanticToken("class", "C"), + c2.semanticToken("class.declaration", "I"), + c2.semanticToken("variable", "M"), + c2.semanticToken("class", "C"), ); diff --git a/tests/cases/fourslash/syntacticClassificationsForOfKeyword.ts b/tests/cases/fourslash/syntacticClassificationsForOfKeyword.ts index 5a2354b380582..6220f77c6fce6 100644 --- a/tests/cases/fourslash/syntacticClassificationsForOfKeyword.ts +++ b/tests/cases/fourslash/syntacticClassificationsForOfKeyword.ts @@ -14,9 +14,9 @@ verify.syntacticClassificationsAre( c.punctuation("{"), c.punctuation("}") ); - -const c2 = classification("2020"); -verify.semanticClassificationsAre("2020", - c2.semanticToken("variable.declaration", "of"), - c2.semanticToken("variable", "of"), + +const c2 = classification("2020"); +verify.semanticClassificationsAre("2020", + c2.semanticToken("variable.declaration.local", "of"), + c2.semanticToken("variable.local", "of"), ); diff --git a/tests/cases/fourslash/syntacticClassificationsForOfKeyword2.ts b/tests/cases/fourslash/syntacticClassificationsForOfKeyword2.ts index 1d8ba78579b93..db49945e1a73f 100644 --- a/tests/cases/fourslash/syntacticClassificationsForOfKeyword2.ts +++ b/tests/cases/fourslash/syntacticClassificationsForOfKeyword2.ts @@ -17,6 +17,6 @@ verify.syntacticClassificationsAre( const c2 = classification("2020"); verify.semanticClassificationsAre("2020", - c2.semanticToken("variable.declaration", "of"), - c2.semanticToken("variable", "of"), + c2.semanticToken("variable.declaration.local", "of"), + c2.semanticToken("variable.local", "of"), ); diff --git a/tests/cases/fourslash/syntacticClassificationsForOfKeyword3.ts b/tests/cases/fourslash/syntacticClassificationsForOfKeyword3.ts index 1e5f8481e5891..3393a4737f3b0 100644 --- a/tests/cases/fourslash/syntacticClassificationsForOfKeyword3.ts +++ b/tests/cases/fourslash/syntacticClassificationsForOfKeyword3.ts @@ -17,9 +17,9 @@ verify.syntacticClassificationsAre( c.punctuation("}") ); -const c2 = classification("2020"); -verify.semanticClassificationsAre("2020", - c2.semanticToken("variable.declaration", "of"), - c2.semanticToken("variable", "of"), - c2.semanticToken("variable", "of"), +const c2 = classification("2020"); +verify.semanticClassificationsAre("2020", + c2.semanticToken("variable.declaration.local", "of"), + c2.semanticToken("variable.local", "of"), + c2.semanticToken("variable.local", "of"), );