From c189c5d214c31620d2e24ecdb64e0c75b8759070 Mon Sep 17 00:00:00 2001 From: Alex Mizuki Date: Fri, 6 Apr 2012 12:05:49 -0400 Subject: [PATCH] failing tests for issue 35 --- .../FormattingTests/TestFormattingBugs.cs | 79 ++++++++++++++++++- 1 file changed, 78 insertions(+), 1 deletion(-) diff --git a/ICSharpCode.NRefactory.Tests/FormattingTests/TestFormattingBugs.cs b/ICSharpCode.NRefactory.Tests/FormattingTests/TestFormattingBugs.cs index dc1087fdb..644be2854 100644 --- a/ICSharpCode.NRefactory.Tests/FormattingTests/TestFormattingBugs.cs +++ b/ICSharpCode.NRefactory.Tests/FormattingTests/TestFormattingBugs.cs @@ -227,7 +227,84 @@ public object GetValue () } }"); } - + + /// + /// Bug GH35 - Formatter issues with if/else statements and // comments + /// + [Test()] + public void TestBugGH35() + { + var policy = new CSharpFormattingOptions(); + policy.ConstructorBraceStyle = BraceStyle.EndOfLine; + + Test(policy, @"public class A : B +{ + public void Test() + { + // Comment before + if (conditionA) { + DoSomething(); + } + // Comment before else ends up incorporating it + else if (conditionB) { + DoSomethingElse(); + } + } +}", +@"public class A : B +{ + public void Test() + { + // Comment before + if (conditionA) { + DoSomething(); + } + // Comment before else ends up incorporating it + else if (conditionB) { + DoSomethingElse(); + } + } +}"); + } + + /// + /// Bug GH35a - Formatter issues with if/else statements and // comments else variant + /// + [Test()] + public void TestBugGH35a() + { + var policy = new CSharpFormattingOptions(); + policy.ConstructorBraceStyle = BraceStyle.EndOfLine; + + Test(policy, @"public class A : B +{ + public void Test() + { + // Comment before + if (conditionA) { + DoSomething(); + } + // Comment before else ends up incorporating it + else (conditionB) { + DoSomethingElse(); + } + } +}", +@"public class A : B +{ + public void Test() + { + // Comment before + if (conditionA) { + DoSomething(); + } + // Comment before else ends up incorporating it + else (conditionB) { + DoSomethingElse(); + } + } +}"); + } } }