Skip to content

Commit b141a47

Browse files
committed
SA1132: add regression test (issue #1554)
1 parent 61bac44 commit b141a47

1 file changed

Lines changed: 28 additions & 0 deletions

File tree

StyleCop.Analyzers/StyleCop.Analyzers.Test/ReadabilityRules/SA1132UnitTests.cs

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,34 @@ class Foo
5757
await this.VerifyCSharpFixAsync(testCode, fixedCode).ConfigureAwait(false);
5858
}
5959

60+
[Fact]
61+
public async Task TestInvalidDeclarationWithTrailingTriviaAsync()
62+
{
63+
const string testCode = @"
64+
class Foo
65+
{
66+
public const int a = 1, // foo
67+
b = 2,
68+
c = 3, // bar
69+
d = 4,
70+
e = 5; /* spam */
71+
}";
72+
const string fixedCode = @"
73+
class Foo
74+
{
75+
public const int a = 1; // foo
76+
public const int b = 2;
77+
public const int c = 3; // bar
78+
public const int d = 4;
79+
public const int e = 5; /* spam */
80+
}";
81+
82+
DiagnosticResult expected = this.CSharpDiagnostic().WithLocation(4, 5);
83+
await this.VerifyCSharpDiagnosticAsync(testCode, expected, CancellationToken.None).ConfigureAwait(false);
84+
await this.VerifyCSharpDiagnosticAsync(fixedCode, EmptyDiagnosticResults, CancellationToken.None).ConfigureAwait(false);
85+
await this.VerifyCSharpFixAsync(testCode, fixedCode).ConfigureAwait(false);
86+
}
87+
6088
[Fact]
6189
public async Task TestInvalidFieldDeclarationWithAttributesAsync()
6290
{

0 commit comments

Comments
 (0)