示例#1
0
        public void Or_FirstSuccess_ReturnsFirstResult()
        {
            var parser = Combine.Or(Parse.Succeed('x'), Parse.Succeed('y'));
            var result = parser.Parse("");

            ParseAssert.ValueEquals('x', result);
        }
示例#2
0
        public void Or_FirstError_ReturnsSecondResult()
        {
            var parser = Combine.Or(Parse.Fail <int>("test"), Parse.Succeed(42));
            var result = parser.Parse("");

            ParseAssert.ValueEquals(42, result);
        }
示例#3
0
        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);
        }