Permalink
Browse files

Improve parsing assertions so that when a parser fails unexpectedly, …

…the position of the failure is included in the test output.
  • Loading branch information...
1 parent 112e42a commit c7fdd022da0ccd033ff6a01ab1f3650ed7bbe8e3 @plioi committed May 19, 2012
Showing with 6 additions and 1 deletion.
  1. +6 −1 src/Parsley/ParsingAssertions.cs
@@ -84,7 +84,12 @@ public static Reply<T> Parses<T>(this Parser<T> parser, IEnumerable<Token> token
private static Reply<T> Succeeds<T>(this Reply<T> reply)
{
if (!reply.Success)
- throw new AssertionException(reply.ErrorMessages.ToString(), "parser success", "parser failed");
+ {
+ var message = "Position: " + reply.UnparsedTokens.Position
+ + Environment.NewLine
+ + "Error Message: " + reply.ErrorMessages;
+ throw new AssertionException(message, "parser success", "parser failed");
+ }
return reply;
}

0 comments on commit c7fdd02

Please sign in to comment.