Ejemplo n.º 1
0
 /**
  * @param int $tokenAmount
  * @param string $text
  * @dataProvider providerTokenAmountAndText
  */
 public function testNoEndAfterUnreadingLastToken(int $tokenAmount, string $text)
 {
     $lexer = Lexer::factory()->setText($text);
     for ($i = 0; $i < $tokenAmount; $i++) {
         $lexer->readToken();
     }
     $lexer->unreadToken();
     $this->assertFalse($lexer->isEnd(), "End condition after unreading token to buffer");
 }
Ejemplo n.º 2
0
 /**
  * Returns lexical analyzer.
  *
  * @return Lexer
  */
 protected function getLexer() : Lexer
 {
     if (null === $this->lexer) {
         $this->lexer = Lexer::factory();
     }
     return $this->lexer;
 }
Ejemplo n.º 3
0
 /**
  * @expectedException \LengthException
  */
 public function testReadingEmptyTextEndThrowsSplException()
 {
     Lexer::factory()->setText('')->readToken();
 }
Ejemplo n.º 4
0
 /**
  * @param string $text
  * @dataProvider providerBrokenUnicodeText
  * @expectedException \RuntimeException
  */
 public function testSettingBrokenUnicodeTextThrowsSplException(string $text)
 {
     Lexer::factory()->setText($text);
 }