コード例 #1
0
ファイル: TokenStreamTest.php プロジェクト: mohiva/common
 /**
  * Test if can get the lookahead token if iterator mode is set to LIFO.
  *
  * @param \com\mohiva\common\parser\TokenStream $stream The token stream to use for this test.
  * @dataProvider tokenStreamProvider
  */
 public function testGetLookaheadInLifoMode(TokenStream $stream)
 {
     // user.name.split(" ").join("-")
     $stream->setIteratorMode(TokenStream::IT_MODE_LIFO);
     $stream->rewind();
     $this->assertSame($stream->getLookahead()->getCode(), self::T_VALUE);
     $this->assertSame($stream->getLookahead(1)->getCode(), self::T_VALUE);
     $stream->next();
     $this->assertSame($stream->getLookahead(1)->getCode(), self::T_OPEN_PARENTHESIS);
     $stream->next();
     $this->assertSame($stream->getLookahead(1)->getCode(), self::T_NAME);
     $stream->next();
     $this->assertSame($stream->getLookahead(1)->getCode(), self::T_POINT);
     $this->assertSame($stream->getLookahead(2)->getCode(), self::T_CLOSE_PARENTHESIS);
     $this->assertSame($stream->getLookahead(3)->getCode(), self::T_VALUE);
     $this->assertSame($stream->getLookahead(4)->getCode(), self::T_OPEN_PARENTHESIS);
     $this->assertSame($stream->getLookahead(5)->getCode(), self::T_NAME);
     $this->assertSame($stream->getLookahead(6)->getCode(), self::T_POINT);
     $this->assertSame($stream->getLookahead(7)->getCode(), self::T_NAME);
     $this->assertSame($stream->getLookahead(8)->getCode(), self::T_POINT);
     $this->assertSame($stream->getLookahead(9)->getCode(), self::T_NAME);
     $this->assertNull($stream->getLookahead(10));
 }