public void Choose_EmptySequence_ReturnsError() { var parser = Parse.Choose <char>(); var result = parser.Parse("z"); ParseAssert.IsError(result); }
public void Satisfy_FailingPredicate_ReturnsError() { var parser = Chars.Satisfy(c => false); var result = parser.Parse("xyz"); ParseAssert.IsError(result); }
public void Between_NonMatchingValue_ReturnsError() { var parser = Chars.Char('x').Between(Chars.Char('['), Chars.Char(']')); var result = parser.Parse("[_]"); ParseAssert.IsError(result); }
public void String_EndOfInput_ReturnsError() { var parser = Chars.String("xyz"); var result = parser.Parse("xy"); ParseAssert.IsError(result); }
public void String_NoMatch_ReturnsError() { var parser = Chars.String("xyz"); var result = parser.Parse("abc"); ParseAssert.IsError(result); }
public void Not_MatchingChar_ReturnsError() { var parser = Chars.Not('x'); var result = parser.Parse("x"); ParseAssert.IsError(result); }
public void EndOfLine_NoMatch_ReturnsError() { var parser = Chars.EndOfLine(); var result = parser.Parse("abc"); ParseAssert.IsError(result); }
public void Any_EmptyStream_ReturnsError() { var parser = Chars.Any(); var result = parser.Parse(""); ParseAssert.IsError(result); }
public void NoneOf_MatchingChar_ReturnsError() { var parser = Chars.NoneOf("abc"); var result = parser.Parse("b"); ParseAssert.IsError(result); }
public void Repeat_CountLargerThanMatching_ReturnsError() { var parser = Chars.Char('x').Repeat(42); var result = parser.Parse("xxxxx"); ParseAssert.IsError(result); }
public void SeparatedBy_ValueAndSeparator_ReturnsError() { var parser = Chars.Any().SeparatedBy(Chars.Char(';')); var result = parser.Parse("x;"); ParseAssert.IsError(result); }
public void Eof_RemainingInput_ReturnsError() { var parser = Parse.Eof <int>(); var result = parser.Parse("abc"); ParseAssert.IsError(result); }
public void NotFollowedBy_ParserBSuccess_ReturnsError() { var parser = Chars.Char('x').NotFollowedBy(Chars.Char('y')); var result = parser.Parse("xy"); ParseAssert.IsError(result); }
public void Char_NonMatchingChar_ReturnsError() { var parser = Chars.Char('x'); var result = parser.Parse("abc"); ParseAssert.IsError(result); }
public void Before_ParserBError_ReturnsError() { var parser = Chars.Char('x').Before(Chars.Char('y')); var result = parser.Parse("xx"); ParseAssert.IsError(result); }
public void FollowedBy_ParserBError_ReturnsError() { var parser = Chars.Char('x').FollowedBy(Chars.Char('y')); var result = parser.Parse("xx"); ParseAssert.IsError(result); }
public void Many1_NoMatch_ReturnsError() { var parser = Chars.Char('x').Many1(); var result = parser.Parse("y"); ParseAssert.IsError(result); }
public void Double_NonNumeric_ReturnsError() { var parser = Numeric.Double(); var result = parser.Parse("test"); ParseAssert.IsError(result); }
public void Int_NoDigit_ReturnsError() { var parser = Numeric.Int(); var result = parser.Parse("xyz"); ParseAssert.IsError(result); }
public void OneOf_NonMatchingChar_ReturnsError() { var parser = Chars.OneOf("xyz"); var result = parser.Parse("a"); ParseAssert.IsError(result); }
public void Sequence_FailingSequence_ReturnsError() { var parser = Parse.Sequence(Chars.Char('x'), Chars.Char('y'), Chars.Char('z')); var result = parser.Parse("xy"); ParseAssert.IsError(result); }
public void Choose_UnsuccesfulParsers_ReturnsError() { var parser = Parse.Choose(Chars.Char('x'), Chars.Char('y'), Chars.Char('z')); var result = parser.Parse("a"); ParseAssert.IsError(result); }
public void Aggregate_ConsumedInputThenError_ReturnsError() { var parser = (from x in Chars.Char('x') from y in Chars.Char('y') select x.ToString() + y.ToString()) .Aggregate(() => "", (acc, c) => acc + c); var result = parser.Parse("xyxz"); ParseAssert.IsError(result); }
public void Try_Error_ReturnsErrorAndResetsPosition() { var parser = Parse.Try(from x in Chars.Any() from y in Chars.Any() from f in Parse.Fail <char>("test") select x); IInputReader input = InputReader.Create("abc"); Position expectedPosition = input.GetPosition(); var result = parser.Parse(input); ParseAssert.IsError(result); Assert.AreEqual(expectedPosition, input.GetPosition()); }