From 92af81a62016cd7d3187dcf9a0c53efad2be45f4 Mon Sep 17 00:00:00 2001 From: Roman Didenko Date: Thu, 15 Jun 2017 14:34:08 -0400 Subject: [PATCH] Added tests for SA1009 that must not be triggered when the closing parenthesis followed by '>' operator --- .../SpacingRules/SA1009UnitTests.cs | 32 +++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test/SpacingRules/SA1009UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test/SpacingRules/SA1009UnitTests.cs index 39543398f..9a04dedba 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test/SpacingRules/SA1009UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test/SpacingRules/SA1009UnitTests.cs @@ -245,6 +245,38 @@ public async Task TestSpaceAfterParenthisisInArithmeticOperationAsync(string ope await this.TestWhitespaceInStatementOrDeclAsync(validStatement, string.Empty, EmptyDiagnosticResults).ConfigureAwait(false); } + [Theory] + [InlineData(">")] + [InlineData(">=")] + [InlineData("<")] + [InlineData("<=")] + [InlineData("==")] + [InlineData("&")] + [InlineData("%")] + [InlineData("^")] + [InlineData("|")] + [InlineData("*")] + [InlineData(">>")] + [InlineData("<<")] + public async Task TestSpaceAfterParenthisisBeforeOperatorAsync(string operatorValue) + { + // e.g. var i = (1 + 1) >= 2 + var validStatement = string.Format(@"var i = (1 + 1) {0} 2;", operatorValue); + + await this.TestWhitespaceInStatementOrDeclAsync(validStatement, string.Empty, EmptyDiagnosticResults).ConfigureAwait(false); + } + + [Theory] + [InlineData("&&")] + [InlineData("||")] + public async Task TestSpaceAfterParenthisisBeforeConditionalOperatorAsync(string operatorValue) + { + // e.g. var i = (1 == 2) || (1 != 2) + var validStatement = string.Format(@"var i = (1 == 2) {0} (1 != 2);", operatorValue); + + await this.TestWhitespaceInStatementOrDeclAsync(validStatement, string.Empty, EmptyDiagnosticResults).ConfigureAwait(false); + } + [Fact] public async Task TestNoSpaceAfterParenthisisInAddOperationAsync() {