From 71f47a687abeec703735bbad77880ea0640f9217 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mike=20Kr=C3=BCger?= Date: Sun, 4 Sep 2011 15:10:06 +0200 Subject: [PATCH] Added more debug output. --- .../CSharp/Parser/ParseSelfTests.cs | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/ICSharpCode.NRefactory.Tests/CSharp/Parser/ParseSelfTests.cs b/ICSharpCode.NRefactory.Tests/CSharp/Parser/ParseSelfTests.cs index 54b8fc8288..c469a73b76 100644 --- a/ICSharpCode.NRefactory.Tests/CSharp/Parser/ParseSelfTests.cs +++ b/ICSharpCode.NRefactory.Tests/CSharp/Parser/ParseSelfTests.cs @@ -70,6 +70,8 @@ namespace ICSharpCode.NRefactory.CSharp.Parser foreach (string fileName in fileNames) { this.currentDocument = new ReadOnlyDocument(File.ReadAllText(fileName)); CompilationUnit cu = parser.Parse(currentDocument.CreateReader()); + if (parser.HasErrors) + continue; this.currentFileName = fileName; CheckPositionConsistency(cu); CheckMissingTokens(cu); @@ -81,7 +83,7 @@ namespace ICSharpCode.NRefactory.CSharp.Parser Console.WriteLine ("Parent:" + node.GetType ()); Console.WriteLine ("Children:"); foreach (var c in node.Children) - Console.WriteLine (c.GetType () +" at:"+ c.StartLocation + " Role: "+ c.Role); + Console.WriteLine (c.GetType () +" at:"+ c.StartLocation +"-"+ c.EndLocation + " Role: "+ c.Role); Console.WriteLine ("----"); } @@ -93,9 +95,12 @@ namespace ICSharpCode.NRefactory.CSharp.Parser var prevNode = node; for (AstNode child = node.FirstChild; child != null; child = child.NextSibling) { bool assertion = child.StartLocation >= prevNodeEnd; - if (!assertion) + if (!assertion) { + PrintNode (prevNode); PrintNode (node); - Assert.IsTrue(assertion, currentFileName + ": Child " + child.GetType () +" (" + child.StartLocation + ")" +" must start after previous sibling " + prevNode.GetType () + "(" + prevNode.StartLocation + ")"); + + } + Assert.IsTrue(assertion, currentFileName + ": Child " + child.GetType () +" (" + child.StartLocation + ")" +" must start after previous sibling " + prevNode.GetType () + "(" + prevNode.StartLocation + ")"); CheckPositionConsistency(child); prevNodeEnd = child.EndLocation; prevNode = child; @@ -129,8 +134,9 @@ namespace ICSharpCode.NRefactory.CSharp.Parser string text = currentDocument.GetText(start, end - start); bool assertion = string.IsNullOrWhiteSpace(text); if (!assertion) { - if (startNode.Parent == endNode.Parent) + if (startNode.Parent != endNode.Parent) PrintNode (startNode.Parent); + PrintNode (endNode.Parent); } Assert.IsTrue(assertion, "Expected whitespace between " + startNode.GetType () +":" + whitespaceStart + " and " + endNode.GetType () + ":" + whitespaceEnd + ", but got '" + text + "' (in " + currentFileName + " parent:" + startNode.Parent.GetType () +")");