GraphQL\Tests\Language\LexerTest::testDoubleLinkedList PHP Метод

testDoubleLinkedList() публичный Метод

    public function testDoubleLinkedList()
    {
        $lexer = new Lexer(new Source('{
      #comment
      field
    }'));
        $startToken = $lexer->token;
        do {
            $endToken = $lexer->advance();
            // Lexer advances over ignored comment tokens to make writing parsers
            // easier, but will include them in the linked list result.
            $this->assertNotEquals('Comment', $endToken->kind);
        } while ($endToken->kind !== '<EOF>');
        $this->assertEquals(null, $startToken->prev);
        $this->assertEquals(null, $endToken->next);
        $tokens = [];
        for ($tok = $startToken; $tok; $tok = $tok->next) {
            if (!empty($tokens)) {
                // Tokens are double-linked, prev should point to last seen token.
                $this->assertSame($tokens[count($tokens) - 1], $tok->prev);
            }
            $tokens[] = $tok;
        }
        $this->assertEquals(['<SOF>', '{', 'Comment', 'Name', '}', '<EOF>'], Utils::map($tokens, function ($tok) {
            return $tok->kind;
        }));
    }