Example #1
0
 public void WithXOr_WhenFirstOptionFailsAndConsumesInput_SecondOptionNotTried()
 {
     var first = Parse.Char('a').Once().Concat(Parse.Char('b').Once());
     var second = Parse.Char('a').Once();
     var p = first.XOr(second);
     AssertParser.FailsAt(p, "a", 1);
 }
Example #2
0
        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);
        }
Example #3
0
 public void NotParserConsumesNoInputOnFailure()
 {
     var notAb = Parse.String("ab").Text().Not();
     AssertParser.FailsAt(notAb, "abc", 0);
 }
Example #4
0
 public void XAtLeastOnceParser_WhenFirstElementFails_FailureReportedAtFirstElement()
 {
     var ab = Parse.String("ab").Text();
     var p = ab.XAtLeastOnce().End();
     AssertParser.FailsAt(p, "d", 0);
 }
Example #5
0
 public void Parser_OfChar_DoesNotAcceptNonMatchingChar()
 {
     AssertParser.FailsAt(Parse.Char('a').Once(), "b", 0);
 }
Example #6
0
 public void XOptionalParserFailsOnPartialMatch()
 {
     var optAbc = Parse.String("abc").Text().XOptional();
     AssertParser.FailsAt(optAbc, "abd", 2);
     AssertParser.FailsAt(optAbc, "aa", 1);
 }