Add benchmark

This commit is contained in:
Ivan Shalganov
2013-01-25 19:13:33 +04:00
parent 164ab85594
commit 4f42efbb9a
16 changed files with 5274 additions and 180 deletions

View File

@ -46,112 +46,6 @@ class TokenizerTest extends \PHPUnit_Framework_TestCase {
$this->assertSame("+", $tokens->getNext($tokens::MACRO_BINARY));
}
public function testWhitespaceSenseLow() {
$text = "1 foo \n bar\n \n double ";
$tokens = new Tokenizer($text, Tokenizer::DECODE_NEW_LINES);
$this->assertTrue($tokens->valid());
$this->assertSame("1", $tokens->current());
$this->assertSame(T_LNUMBER, $tokens->key());
$this->assertSame(" ", $tokens->getWhiteSpace());
$tokens->next();
$this->assertTrue($tokens->valid());
$this->assertSame("foo", $tokens->current());
$this->assertSame(T_STRING, $tokens->key());
$this->assertSame(" ", $tokens->getWhiteSpace());
$tokens->next();
$this->assertTrue($tokens->valid());
$this->assertSame("\n", $tokens->current());
$this->assertSame(T_WHITESPACE, $tokens->key());
$this->assertSame(" ", $tokens->getWhiteSpace());
$tokens->next();
$this->assertTrue($tokens->valid());
$this->assertSame("bar", $tokens->current());
$this->assertSame(T_STRING, $tokens->key());
$this->assertSame("", $tokens->getWhiteSpace());
$tokens->next();
$this->assertTrue($tokens->valid());
$this->assertSame("\n", $tokens->current());
$this->assertSame(T_WHITESPACE, $tokens->key());
$this->assertSame(" ", $tokens->getWhiteSpace());
$tokens->next();
$this->assertTrue($tokens->valid());
$this->assertSame("\n", $tokens->current());
$this->assertSame(T_WHITESPACE, $tokens->key());
$this->assertSame(" ", $tokens->getWhiteSpace());
$tokens->next();
$this->assertTrue($tokens->valid());
$this->assertSame("double", $tokens->current());
$this->assertSame(T_STRING, $tokens->key());
$this->assertSame(" ", $tokens->getWhiteSpace());
$tokens->next();
$this->assertFalse($tokens->valid());
$this->assertNull($tokens->key());
}
public function testWhitespaceSenseHi() {
$text = "1 foo \n bar\n \n double ";
$tokens = new Tokenizer($text, Tokenizer::DECODE_WHITESPACES);
$this->assertTrue($tokens->valid());
$this->assertSame("1", $tokens->current());
$this->assertSame(T_LNUMBER, $tokens->key());
$this->assertSame("", $tokens->getWhiteSpace());
$tokens->next();
$this->assertTrue($tokens->valid());
$this->assertSame(" ", $tokens->current());
$this->assertSame(T_WHITESPACE, $tokens->key());
$this->assertSame("", $tokens->getWhiteSpace());
$tokens->next();
$this->assertTrue($tokens->valid());
$this->assertSame("foo", $tokens->current());
$this->assertSame(T_STRING, $tokens->key());
$this->assertSame("", $tokens->getWhiteSpace());
$tokens->next();
$this->assertTrue($tokens->valid());
$this->assertSame(" \n ", $tokens->current());
$this->assertSame(T_WHITESPACE, $tokens->key());
$this->assertSame("", $tokens->getWhiteSpace());
$tokens->next();
$this->assertTrue($tokens->valid());
$this->assertSame("bar", $tokens->current());
$this->assertSame(T_STRING, $tokens->key());
$this->assertSame("", $tokens->getWhiteSpace());
$tokens->next();
$this->assertTrue($tokens->valid());
$this->assertSame("\n \n ", $tokens->current());
$this->assertSame(T_WHITESPACE, $tokens->key());
$this->assertSame("", $tokens->getWhiteSpace());
$tokens->next();
$this->assertTrue($tokens->valid());
$this->assertSame("double", $tokens->current());
$this->assertSame(T_STRING, $tokens->key());
$this->assertSame("", $tokens->getWhiteSpace());
$tokens->next();
$this->assertTrue($tokens->valid());
$this->assertSame(" ", $tokens->current());
$this->assertSame(T_WHITESPACE, $tokens->key());
$this->assertSame("", $tokens->getWhiteSpace());
$tokens->next();
$this->assertFalse($tokens->valid());
$this->assertNull($tokens->key());
}
public function testSkip() {
$text = "1 foo: bar ( 3 + double ) ";
$tokens = new Tokenizer($text);