Esempio n. 1
0
        public void DoesNotChangeStateAsUnderlyingEnumeratorIsTraversed()
        {
            var tokens = new TokenStream(Tokens());

            var first = tokens;

            first.Current.ShouldEqual(upper, "ABC", 1, 1);

            var second = first.Advance();
            first.Current.ShouldEqual(upper, "ABC", 1, 1);
            second.Current.ShouldEqual(lower, "def", 1, 4);

            var third = second.Advance();
            first.Current.ShouldEqual(upper, "ABC", 1, 1);
            second.Current.ShouldEqual(lower, "def", 1, 4);
            third.Current.ShouldEqual(upper, "GHI", 1, 7);

            var fourth = third.Advance();
            first.Current.ShouldEqual(upper, "ABC", 1, 1);
            second.Current.ShouldEqual(lower, "def", 1, 4);
            third.Current.ShouldEqual(upper, "GHI", 1, 7);
            fourth.Current.ShouldEqual(TokenKind.EndOfInput, "", 1, 10);

            fourth.Advance().ShouldBeSameAs(fourth);
        }
Esempio n. 2
0
        public void AllowsRepeatableTraversalWhileTraversingUnderlyingEnumeratorItemsAtMostOnce()
        {
            var tokens = new TokenStream(Tokens());

            tokens.Current.ShouldEqual(upper, "ABC", 1, 1);
            tokens.Advance().Current.ShouldEqual(lower, "def", 1, 4);
            tokens.Advance().Advance().Current.ShouldEqual(upper, "GHI", 1, 7);
            tokens.Advance().Advance().Advance().Current.ShouldEqual(TokenKind.EndOfInput, "", 1, 10);

            tokens.Advance().ShouldBeSameAs(tokens.Advance());
        }
Esempio n. 3
0
 public ParsedTests()
 {
     unparsed = new TokenStream(new CharLexer().Tokenize("0"));
 }
Esempio n. 4
0
        public void ProvidesEndOfInputTokenWhenGivenEmptyEnumerator()
        {
            var tokens = new TokenStream(Empty());

            tokens.Current.ShouldEqual(TokenKind.EndOfInput, "", 1, 1);
            tokens.Advance().ShouldBeSameAs(tokens);
        }
Esempio n. 5
0
        public void ProvidesEndOfInputTokenAfterEnumeratorIsExhausted()
        {
            var tokens = new TokenStream(OneToken());
            var end = tokens.Advance();

            end.Current.ShouldEqual(TokenKind.EndOfInput, "", 1, 4);
            end.Advance().ShouldBeSameAs(end);
        }
Esempio n. 6
0
 public void ProvidesCurrentToken()
 {
     var tokens = new TokenStream(Tokens());
     tokens.Current.ShouldEqual(upper, "ABC", 1, 1);
 }
Esempio n. 7
0
 public void AdvancesToTheNextToken()
 {
     var tokens = new TokenStream(Tokens());
     tokens.Advance().Current.ShouldEqual(lower, "def", 1, 4);
 }
Esempio n. 8
0
 public void TryingToAdvanceBeyondEndOfInputResultsInNoMovement()
 {
     var tokens = new TokenStream(Empty());
     tokens.ShouldBeSameAs(tokens.Advance());
 }
Esempio n. 9
0
        public void ProvidesPositionOfCurrentToken()
        {
            var tokens = new TokenStream(Tokens());

            tokens.Position.Line.ShouldEqual(1);
            tokens.Position.Column.ShouldEqual(1);

            tokens.Advance().Position.Line.ShouldEqual(1);
            tokens.Advance().Position.Column.ShouldEqual(4);

            tokens.Advance().Advance().Position.Line.ShouldEqual(1);
            tokens.Advance().Advance().Position.Column.ShouldEqual(7);

            tokens.Advance().Advance().Advance().Position.Line.ShouldEqual(1);
            tokens.Advance().Advance().Advance().Position.Column.ShouldEqual(10);
        }