public static void FailsWith <T>(TokenListParser <char, T> parser, string input, Action <TokenListParserResult <char, T> > resultAssertion) { var result = parser.TryParse(StringAsCharTokenList.Tokenize((input))); if (result.HasValue) { Assert.False(result.HasValue, $"Expected failure but succeeded with {result.Value}."); } resultAssertion(result); }
public static void FailsWithMessage <T>(TokenListParser <char, T> parser, string input, string message) { var result = parser.TryParse(StringAsCharTokenList.Tokenize(input)); Assert.Equal(message, result.ToString()); }
public static void Succeeds <T>(TokenListParser <char, T> parser, string input, Action <T> resultAssertion) { var t = parser.Parse(StringAsCharTokenList.Tokenize(input)); resultAssertion(t); }