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