From 1b45b0eeaa676350c2bf7b4d92899c59fc0d3f2d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Erik=20K=C3=A4ll=C3=A9n?= Date: Wed, 10 Oct 2012 00:23:37 +0200 Subject: [PATCH] Bug with comment just before try/catch/finally statement. --- .../Statements/TryCatchStatementTests.cs | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/ICSharpCode.NRefactory.Tests/CSharp/Parser/Statements/TryCatchStatementTests.cs b/ICSharpCode.NRefactory.Tests/CSharp/Parser/Statements/TryCatchStatementTests.cs index 61e9b26609..f31fcae318 100644 --- a/ICSharpCode.NRefactory.Tests/CSharp/Parser/Statements/TryCatchStatementTests.cs +++ b/ICSharpCode.NRefactory.Tests/CSharp/Parser/Statements/TryCatchStatementTests.cs @@ -85,5 +85,23 @@ namespace ICSharpCode.NRefactory.CSharp.Parser.Statements Assert.IsFalse(c1.IsMatch(c2)); Assert.IsFalse(c2.IsMatch(c1)); // and vice versa } + + [Test] + public void CommentBeforeTryCatchFinally() + { + var stmt = ParseUtilCSharp.ParseStatement( +@"{ + //Comment before + try { } catch { } finally { } + //Comment after +}"); + var children = stmt.Children.ToList(); + Assert.That(children.Count, Is.EqualTo(5)); + Assert.That(children[0].Role, Is.EqualTo(Roles.LBrace)); + Assert.That(children[1].Role, Is.EqualTo(Roles.Comment)); + Assert.That(children[2].Role, Is.EqualTo(BlockStatement.StatementRole)); + Assert.That(children[3].Role, Is.EqualTo(Roles.Comment)); + Assert.That(children[4].Role, Is.EqualTo(Roles.RBrace)); + } } }