public void CanSpecifyParsersUsingQueryComprehensions() { var p = from a in Parse.Char('a').Once() from bs in Parse.Char('b').Many() from cs in Parse.Char('c').AtLeastOnce() select a.Concat(bs).Concat(cs); AssertParser.SucceedsWithAll(p, "abbbc"); }
public void WithXMany_WhenLastElementFails_FailureReportedAtLastElement() { var ab = from a in Parse.Char('a') from b in Parse.Char('b') select "ab"; var p = ab.XMany().End(); AssertParser.FailsAt(p, "ababaf", 5); }
public void FailGracefullyOnSequence() { var sequence = Parse.Char('a').XDelimitedBy(Parse.Char(',')); AssertParser.FailsWith(sequence, "a,a,b", result => { StringAssert.Contains("unexpected 'b'", result.Message); CollectionAssert.Contains(result.Expectations, "a"); }); }
public void Parser_OfChar_DoesNotAcceptNonMatchingChar() { AssertParser.FailsAt(Parse.Char('a').Once(), "b", 0); }
public void ExceptStopsConsumingInputWhenExclusionParsed() { var exceptAa = Parse.AnyChar.Except(Parse.String("aa")).Many().Text(); AssertParser.SucceedsWith(exceptAa, "abcaab", r => Assert.AreEqual("abc", r)); }
public void TestSelectManyNone() => AssertParser.SucceedsWith(ParserOptionalSelectMany, "b", o => Assert.True(o.IsEmpty));
public void Parser_OfAtLeastOneChar_AcceptsManyChars() { AssertParser.SucceedsWithAll(Parse.Char('a').AtLeastOnce(), "aaa"); }
public void Parser_OfManyChars_AcceptsManyChars() { AssertParser.SucceedsWithAll(Parse.Char('a').Many(), "aaa"); }
public void RecursiveParserWithoutLeftRecursion() => AssertParser.SucceedsWith(Parser2UnderTest, "ababba0", o => Assert.Equal("ababba0", o));
public void MultipleRefs() => AssertParser.SucceedsWith(Parser1UnderTest, "id=1", o => Assert.Equal("id", o));
public void CanParseMutuallyLeftRecursiveGrammar() { AssertParser.SucceedsWithAll(ABSeq.End(), "baba"); }
public void CanParseLeftRecursiveGrammar() { AssertParser.SucceedsWith(ASeq.End(), "a,a,a", r => new string(r.ToArray()).Equals("aaa")); }
public void TestSelectManyLinq() => AssertParser.SucceedsWith(ParserOptionalLinq, "ab", o => AssertSome(o, "ba"));
public void NotParserConsumesNoInputOnFailure() { var notAb = Parse.String("ab").Text().Not(); AssertParser.FailsAt(notAb, "abc", 0); }
public void EmptyAlternative1() => AssertParser.SucceedsWith(Parser5UnderTest, "_+_+a", o => Assert.Equal("_+_+", o));
public void IgnoreCaseParser() { var ab = Parse.IgnoreCase("ab").Text(); AssertParser.SucceedsWith(ab, "Ab", m => Assert.AreEqual("Ab", m)); }
public void WhenFirstOptionSucceedsButConsumesNothing_SecondOptionTried() { var p = Parse.Char('a').Many().XOr(Parse.Char('b').Many()); AssertParser.SucceedsWithAll(p, "bbb"); }
public void Parser_OfManyChars_AcceptsEmptyInput() { AssertParser.SucceedsWithAll(Parse.Char('a').Many(), ""); }
public void ParsesString_AsSequenceOfChars() { var p = Parse.String("abc"); AssertParser.SucceedsWithAll(p, "abc"); }
public void Parser_OfAtLeastOneChar_DoesNotAcceptEmptyInput() { AssertParser.Fails(Parse.Char('a').AtLeastOnce(), ""); }
public void Parser_OfChar_AcceptsOnlyOneChar() { AssertParser.SucceedsWithOne(Parse.Char('a').Once(), "aaa", 'a'); }
public void ReturningValue_DoesNotAdvanceInput() { var p = Parse.Return(1); AssertParser.SucceedsWith(p, "abc", n => Assert.AreEqual(1, n)); }
public void TestSelect() => AssertParser.SucceedsWith(ParserOptionalSelect, "a", o => AssertSome(o, 'A'));