public void Int_NoDigit_ReturnsError() { var parser = Numeric.Int(); 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 Between_RepeatingValue_ReturnsValue() { var parser = Chars.NoneOf("]").Many().Between(Chars.Char('['), Chars.Char(']')); var result = parser.Parse("[xyz]"); ParseAssert.ValueEquals("xyz", result); }
public void Repeat_CountZero_ReturnsEmptyResult() { var parser = Chars.Char('x').Repeat(0); var result = parser.Parse("xxxxx"); ParseAssert.ValueEquals(new char[0], result); }
public void Repeat_CountThree_ReturnsThreeMatches() { var parser = Chars.Char('x').Repeat(3); var result = parser.Parse("xxxxx"); ParseAssert.ValueEquals(new char[] { 'x', 'x', 'x' }, result); }
public void SeparatedBy_ValueOnly_ReturnsValue() { var parser = Chars.Any().SeparatedBy(Chars.Char(';')); var result = parser.Parse("x"); ParseAssert.ValueEquals(new char[] { 'x' }, result); }
public void SeparatedBy_ValueAndSeparator_ReturnsError() { var parser = Chars.Any().SeparatedBy(Chars.Char(';')); var result = parser.Parse("x;"); ParseAssert.IsError(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 Many_NoMatch_ReturnsEmptySet() { var parser = Chars.Char('x').Many(); var result = parser.Parse("y"); ParseAssert.ValueEquals("", result); }
public void Double_Int_ReturnsDoubleValue() { var parser = Numeric.Double(); var result = parser.Parse("42"); ParseAssert.ValueEquals(42, result); }
public void Double_IntThenFraction_ReturnsDoubleValue() { var parser = Numeric.Double(); var result = parser.Parse("42.37"); ParseAssert.ValueEquals(42.37, result); }
public void Double_NonNumeric_ReturnsError() { var parser = Numeric.Double(); var result = parser.Parse("test"); ParseAssert.IsError(result); }
public void Int_Plus_ReturnIntValue() { var parser = Numeric.Int(); var result = parser.Parse("+42xyz"); ParseAssert.ValueEquals(42, result); }
public void Int_Negative_ReturnsIntValue() { var parser = Numeric.Int(); var result = parser.Parse("-42xyz"); ParseAssert.ValueEquals(-42, 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 Many1_NoMatch_ReturnsError() { var parser = Chars.Char('x').Many1(); var result = parser.Parse("y"); ParseAssert.IsError(result); }
public void SeparatedBy_Nothing_ReturnsEmptyValue() { var parser = Chars.Any().SeparatedBy(Chars.Char(';')); var result = parser.Parse(""); ParseAssert.ValueEquals(new char[] { }, result); }
public void Many1_OneMatch_ReturnsSetWithOneMatch() { var parser = Chars.Char('x').Many1(); var result = parser.Parse("xy"); ParseAssert.ValueEquals("x", result); }
public void Before_ParserABSuccess_ReturnsParserBResult() { var parser = Chars.Char('x').Before(Chars.Char('y')); var result = parser.Parse("xy"); ParseAssert.ValueEquals('y', result); }
public void Many1_ManyMatches_ReturnsSet() { var parser = Chars.OneOf("xyz").Many1(); var result = parser.Parse("xxyz"); ParseAssert.ValueEquals("xxyz", result); }
public void SeparatedBy_MultipleValues_ReturnsValues() { var parser = Chars.Any().SeparatedBy(Chars.Char(';')); var result = parser.Parse("x;y;z"); ParseAssert.ValueEquals(new char[] { 'x', 'y', 'z' }, 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 Repeat_CountOne_ReturnsSingleMatch() { var parser = Chars.Char('x').Repeat(1); var result = parser.Parse("xxxxx"); ParseAssert.ValueEquals(new char[] { 'x' }, 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 Repeat_CountLargerThanMatching_ReturnsError() { var parser = Chars.Char('x').Repeat(42); var result = parser.Parse("xxxxx"); ParseAssert.IsError(result); }
public void FollowedBy_ParserABSuccess_ReturnsParserAResult() { var parser = Chars.Char('x').FollowedBy(Chars.Char('y')); var result = parser.Parse("xy"); ParseAssert.ValueEquals('x', result); }
public void Between_AllMatching_ReturnsValue() { var parser = Chars.Any().Between(Chars.Char('['), Chars.Char(']')); var result = parser.Parse("[x]"); ParseAssert.ValueEquals('x', result); }
public void NotFollowedBy_ParserBError_ReturnsParserAValue() { var parser = Chars.Char('x').NotFollowedBy(Chars.Char('y')); var result = parser.Parse("xz"); ParseAssert.ValueEquals('x', result); }
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 OneOf_NonMatchingChar_ReturnsError() { var parser = Chars.OneOf("xyz"); var result = parser.Parse("a"); ParseAssert.IsError(result); }