public void Or_FirstSuccess_ReturnsFirstResult() { var parser = Combine.Or(Parse.Succeed('x'), Parse.Succeed('y')); var result = parser.Parse(""); ParseAssert.ValueEquals('x', result); }
public void Or_FirstError_ReturnsSecondResult() { var parser = Combine.Or(Parse.Fail <int>("test"), Parse.Succeed(42)); var result = parser.Parse(""); ParseAssert.ValueEquals(42, result); }
public void Or_FirstErrorConsumesInput_ReturnsFirstError() { var parserA = from x in Chars.Any() from y in Parse.Fail <char>("test") select y; var parserB = Chars.Any(); var parser = Combine.Or(parserA, parserB); var result = parser.Parse("abc"); ParseAssert.ErrorEquals("test", result); }