Beispiel #1
0
        public void AndTest()
        {
            Combinator.And(Combinator.Sequence("inpXtString".Select(Chars.Char)))
            .Run("inputString".AsStream())
            .Case(
                failure: (restStream, _) =>
            {
                Assert.True(restStream.Current.HasValue);
                Assert.AreEqual('i', restStream.Current.Value.Item0);
                Assert.AreEqual(1, restStream.Current.Value.Item1.Line);
                Assert.AreEqual(1, restStream.Current.Value.Item1.Column);
            },
                success: (restStream, value) => Assert.Fail());

            Combinator.And(Combinator.Sequence("inputString".Select(Chars.Char)))
            .Run("inputString".AsStream())
            .Case(
                failure: (restStream, _) => Assert.Fail(),
                success: (restStream, value) =>
            {
                Assert.True(restStream.Current.HasValue);
                Assert.AreEqual('i', restStream.Current.Value.Item0);
                Assert.AreEqual(1, restStream.Current.Value.Item1.Line);
                Assert.AreEqual(1, restStream.Current.Value.Item1.Column);
            });
        }