Skip to content

Commit

Permalink
test for RecordStructName
Browse files Browse the repository at this point in the history
  • Loading branch information
filipw committed Sep 7, 2021
1 parent 91d5fae commit 72030e7
Showing 1 changed file with 40 additions and 0 deletions.
40 changes: 40 additions & 0 deletions tests/OmniSharp.Roslyn.CSharp.Tests/SemanticHighlightFacts.cs
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,45 @@ record R1(string S, int I);
);
}

[Fact]
public async Task SemanticHighlightRecordStructName()
{
var testFile = new TestFile("a.cs", @"
R1 r1 = new R1(string.Empty, 1);
record struct R1(string S, int I);
");

var highlights = await GetSemanticHighlightsForFileAsync(testFile);

AssertSyntax(highlights, testFile.Content.Code, 0,
StructName("R1"),
Local("r1"),
Operator("="),
Keyword("new"),
StructName("R1"),
Punctuation("("),
Keyword("string"),
Operator("."),
Field("Empty", SemanticHighlightModifier.Static),
Punctuation(","),
Number("1"),
Punctuation(")"),
Punctuation(";"),

Keyword("record"),
Keyword("struct"),
StructName("R1"),
Punctuation("("),
Keyword("string"),
Parameter("S"),
Punctuation(","),
Keyword("int"),
Parameter("I"),
Punctuation(")"),
Punctuation(";")
);
}

private Task<SemanticHighlightSpan[]> GetSemanticHighlightsForFileAsync(TestFile testFile)
{
return GetSemanticHighlightsAsync(testFile, range: null);
Expand Down Expand Up @@ -352,6 +391,7 @@ private static void AssertSyntax(SemanticHighlightSpan[] highlights, string code
private static (SemanticHighlightClassification type, string text, SemanticHighlightModifier[] modifiers) Method(string text, params SemanticHighlightModifier[] modifiers) => (SemanticHighlightClassification.MethodName, text, modifiers);
private static (SemanticHighlightClassification type, string text, SemanticHighlightModifier[] modifiers) Local(string text, params SemanticHighlightModifier[] modifiers) => (SemanticHighlightClassification.LocalName, text, modifiers);
private static (SemanticHighlightClassification type, string text, SemanticHighlightModifier[] modifiers) ClassName(string text, params SemanticHighlightModifier[] modifiers) => (SemanticHighlightClassification.ClassName, text, modifiers);
private static (SemanticHighlightClassification type, string text, SemanticHighlightModifier[] modifiers) StructName(string text, params SemanticHighlightModifier[] modifiers) => (SemanticHighlightClassification.StructName, text, modifiers);
private static (SemanticHighlightClassification type, string text, SemanticHighlightModifier[] modifiers) Field(string text, params SemanticHighlightModifier[] modifiers) => (SemanticHighlightClassification.FieldName, text, modifiers);
private static (SemanticHighlightClassification type, string text, SemanticHighlightModifier[] modifiers) Identifier(string text, params SemanticHighlightModifier[] modifiers) => (SemanticHighlightClassification.Identifier, text, modifiers);
private static (SemanticHighlightClassification type, string text, SemanticHighlightModifier[] modifiers) Parameter(string text, params SemanticHighlightModifier[] modifiers) => (SemanticHighlightClassification.ParameterName, text, modifiers);
Expand Down

0 comments on commit 72030e7

Please sign in to comment.