예제 #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");
 }
예제 #2
0
 /**
  * Returns lexical analyzer.
  *
  * @return Lexer
  */
 protected function getLexer() : Lexer
 {
     if (null === $this->lexer) {
         $this->lexer = Lexer::factory();
     }
     return $this->lexer;
 }
예제 #3
0
 /**
  * @expectedException \LengthException
  */
 public function testReadingEmptyTextEndThrowsSplException()
 {
     Lexer::factory()->setText('')->readToken();
 }
예제 #4
0
 /**
  * @param string $text
  * @dataProvider providerBrokenUnicodeText
  * @expectedException \RuntimeException
  */
 public function testSettingBrokenUnicodeTextThrowsSplException(string $text)
 {
     Lexer::factory()->setText($text);
 }