From 7be2d2866b5f83af4b6ccbeef4a64bdc2ed9a1d9 Mon Sep 17 00:00:00 2001 From: Cyrus Najmabadi Date: Mon, 15 Sep 2014 17:39:48 -0700 Subject: [PATCH] Classification tests. --- tests/cases/fourslash/fourslash.ts | 4 +++ .../fourslash/semanticClassification1.ts | 12 +++++++ .../fourslash/syntacticClassifications1.ts | 36 +++++++++++++++++++ 3 files changed, 52 insertions(+) create mode 100644 tests/cases/fourslash/semanticClassification1.ts create mode 100644 tests/cases/fourslash/syntacticClassifications1.ts diff --git a/tests/cases/fourslash/fourslash.ts b/tests/cases/fourslash/fourslash.ts index df4e3b31730..e1b1e26c3c2 100644 --- a/tests/cases/fourslash/fourslash.ts +++ b/tests/cases/fourslash/fourslash.ts @@ -386,6 +386,10 @@ module FourSlashInterface { public syntacticClassificationsAre(...classifications: { classificationType: string; text: string }[]) { FourSlash.currentTestState.verifySyntacticClassifications(classifications); } + + public semanticClassificationsAre(...classifications: { classificationType: string; text: string }[]) { + FourSlash.currentTestState.verifySemanticClassifications(classifications); + } } export class edit { diff --git a/tests/cases/fourslash/semanticClassification1.ts b/tests/cases/fourslash/semanticClassification1.ts new file mode 100644 index 00000000000..0a0cc68250e --- /dev/null +++ b/tests/cases/fourslash/semanticClassification1.ts @@ -0,0 +1,12 @@ +/// + +//// module M { +//// export interface I { +//// } +//// } +//// interface X extends M.I { } + +debugger; +var c = classification; +verify.semanticClassificationsAre( + c.moduleName("M"), c.interfaceName("I"), c.interfaceName("X"), c.moduleName("M"), c.interfaceName("I")); diff --git a/tests/cases/fourslash/syntacticClassifications1.ts b/tests/cases/fourslash/syntacticClassifications1.ts new file mode 100644 index 00000000000..e70a4b672ff --- /dev/null +++ b/tests/cases/fourslash/syntacticClassifications1.ts @@ -0,0 +1,36 @@ +/// + +//// // comment +//// module M { +//// var v = 0 + 1; +//// var s = "string"; +//// +//// class C { +//// } +//// +//// enum E { +//// } +//// +//// interface I { +//// } +//// +//// module M1.M2 { +//// } +//// } + +debugger; +var c = classification; +verify.syntacticClassificationsAre( + c.comment("// comment"), + c.keyword("module"), c.moduleName("M"), c.punctuation("{"), + c.keyword("var"), c.text("v"), c.operator("="), c.numericLiteral("0"), c.operator("+"), c.numericLiteral("1"), c.punctuation(";"), + c.keyword("var"), c.text("s"), c.operator("="), c.stringLiteral('"string"'), c.punctuation(";"), + c.keyword("class"), c.className("C"), c.punctuation("<"), c.typeParameterName("T"), c.punctuation(">"), c.punctuation("{"), + c.punctuation("}"), + c.keyword("enum"), c.enumName("E"), c.punctuation("{"), + c.punctuation("}"), + c.keyword("interface"), c.interfaceName("I"), c.punctuation("{"), + c.punctuation("}"), + c.keyword("module"), c.moduleName("M1"), c.punctuation("."), c.moduleName("M2"), c.punctuation("{"), + c.punctuation("}"), + c.punctuation("}")); \ No newline at end of file