Пример #1
0
        public void TestWhiteSpaceMatcher()
        {
            WhiteSpaceMatcher matcher   = new WhiteSpaceMatcher();
            StringTokenizer   data      = new StringTokenizer(" ,   \n   test ");
            SourcePosition    streamPos = new SourcePosition(0, 0, 0);

            // Match a single whitespace
            Assert.AreEqual(matcher.MatchNext(data, ref streamPos, Log).Type, TokenType.WhiteSpace);
            Assert.AreEqual(data.CurrentItem, ",");
            data.Advance();
            // Match a longer mixed whitespace and check that all of it is discarded
            Assert.IsNull(matcher.MatchNext(data, ref streamPos, Log).Value);
            Assert.AreEqual(data.CurrentItem, "t");
            data.Advance(4);
            // Match EOF whitespace
            Assert.IsNotNull(matcher.MatchNext(data, ref streamPos, Log));

            Assert.IsTrue(data.AtEnd());
        }
Пример #2
0
        public void TestWhiteSpaceMatcher()
        {
            WhiteSpaceMatcher matcher = new WhiteSpaceMatcher();
            StringTokenizer data = new StringTokenizer(" ,   \n   test ");
            SourcePosition streamPos = new SourcePosition(0, 0, 0);

            // Match a single whitespace
            Assert.AreEqual(matcher.MatchNext(data, ref streamPos, Log).Type, TokenType.WhiteSpace);
            Assert.AreEqual(data.CurrentItem, ",");
            data.Advance();
            // Match a longer mixed whitespace and check that all of it is discarded
            Assert.IsNull(matcher.MatchNext(data, ref streamPos, Log).Value);
            Assert.AreEqual(data.CurrentItem, "t");
            data.Advance(4);
            // Match EOF whitespace
            Assert.IsNotNull(matcher.MatchNext(data, ref streamPos, Log));

            Assert.IsTrue(data.AtEnd());
        }