Beispiel #1
0
        public void Choose_EmptySequence_ReturnsError()
        {
            var parser = Parse.Choose <char>();
            var result = parser.Parse("z");

            ParseAssert.IsError(result);
        }
Beispiel #2
0
        public void Satisfy_FailingPredicate_ReturnsError()
        {
            var parser = Chars.Satisfy(c => false);
            var result = parser.Parse("xyz");

            ParseAssert.IsError(result);
        }
Beispiel #3
0
        public void Between_NonMatchingValue_ReturnsError()
        {
            var parser = Chars.Char('x').Between(Chars.Char('['), Chars.Char(']'));
            var result = parser.Parse("[_]");

            ParseAssert.IsError(result);
        }
Beispiel #4
0
        public void String_EndOfInput_ReturnsError()
        {
            var parser = Chars.String("xyz");
            var result = parser.Parse("xy");

            ParseAssert.IsError(result);
        }
Beispiel #5
0
        public void String_NoMatch_ReturnsError()
        {
            var parser = Chars.String("xyz");
            var result = parser.Parse("abc");

            ParseAssert.IsError(result);
        }
Beispiel #6
0
        public void Not_MatchingChar_ReturnsError()
        {
            var parser = Chars.Not('x');
            var result = parser.Parse("x");

            ParseAssert.IsError(result);
        }
Beispiel #7
0
        public void EndOfLine_NoMatch_ReturnsError()
        {
            var parser = Chars.EndOfLine();
            var result = parser.Parse("abc");

            ParseAssert.IsError(result);
        }
Beispiel #8
0
        public void Any_EmptyStream_ReturnsError()
        {
            var parser = Chars.Any();
            var result = parser.Parse("");

            ParseAssert.IsError(result);
        }
Beispiel #9
0
        public void NoneOf_MatchingChar_ReturnsError()
        {
            var parser = Chars.NoneOf("abc");
            var result = parser.Parse("b");

            ParseAssert.IsError(result);
        }
Beispiel #10
0
        public void Repeat_CountLargerThanMatching_ReturnsError()
        {
            var parser = Chars.Char('x').Repeat(42);
            var result = parser.Parse("xxxxx");

            ParseAssert.IsError(result);
        }
Beispiel #11
0
        public void SeparatedBy_ValueAndSeparator_ReturnsError()
        {
            var parser = Chars.Any().SeparatedBy(Chars.Char(';'));
            var result = parser.Parse("x;");

            ParseAssert.IsError(result);
        }
Beispiel #12
0
        public void Eof_RemainingInput_ReturnsError()
        {
            var parser = Parse.Eof <int>();
            var result = parser.Parse("abc");

            ParseAssert.IsError(result);
        }
Beispiel #13
0
        public void NotFollowedBy_ParserBSuccess_ReturnsError()
        {
            var parser = Chars.Char('x').NotFollowedBy(Chars.Char('y'));
            var result = parser.Parse("xy");

            ParseAssert.IsError(result);
        }
Beispiel #14
0
        public void Char_NonMatchingChar_ReturnsError()
        {
            var parser = Chars.Char('x');
            var result = parser.Parse("abc");

            ParseAssert.IsError(result);
        }
Beispiel #15
0
        public void Before_ParserBError_ReturnsError()
        {
            var parser = Chars.Char('x').Before(Chars.Char('y'));
            var result = parser.Parse("xx");

            ParseAssert.IsError(result);
        }
Beispiel #16
0
        public void FollowedBy_ParserBError_ReturnsError()
        {
            var parser = Chars.Char('x').FollowedBy(Chars.Char('y'));
            var result = parser.Parse("xx");

            ParseAssert.IsError(result);
        }
Beispiel #17
0
        public void Many1_NoMatch_ReturnsError()
        {
            var parser = Chars.Char('x').Many1();
            var result = parser.Parse("y");

            ParseAssert.IsError(result);
        }
Beispiel #18
0
        public void Double_NonNumeric_ReturnsError()
        {
            var parser = Numeric.Double();
            var result = parser.Parse("test");

            ParseAssert.IsError(result);
        }
Beispiel #19
0
        public void Int_NoDigit_ReturnsError()
        {
            var parser = Numeric.Int();
            var result = parser.Parse("xyz");

            ParseAssert.IsError(result);
        }
Beispiel #20
0
        public void OneOf_NonMatchingChar_ReturnsError()
        {
            var parser = Chars.OneOf("xyz");
            var result = parser.Parse("a");

            ParseAssert.IsError(result);
        }
Beispiel #21
0
        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);
        }
Beispiel #22
0
        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);
        }
Beispiel #23
0
        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);
        }
Beispiel #24
0
        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());
        }