require 'lexer/xfLexeme.class.php'; require 'util/xfException.class.php'; $t = new lime_test(20, new lime_output_color()); $b = new xfLexemeBuilder('symfony pròject'); $t->is($b->getPosition(), -1, '->getPosition() is negative when processing has not started.'); $t->is($b->getLexemes(), array(), '->getLexemes() is empty when processing has not started.'); $t->is($b->getCharacter(), null, '->getCharacter() is null when processing has not started.'); $b->next(); $t->is($b->getPosition(), 0, '->next() advances the pointer'); $t->is($b->getCharacter(), 's', '->getCharacter() returns the current pointer.'); for ($x = 0; $x < 4; $x++) { $b->addToLexeme($b->getCharacter()); $b->next(); } $b->setType('foobar'); $b->commit(); $t->is($b->count(), 1, '->addToLexeme(), ->commit() create lexemes'); $t->is($b->getLexeme(0)->getLexeme(), 'symf', '->getLexeme() returns the lexeme by index.'); $t->is($b->getLexeme(0)->getType(), 'foobar', '->commit() sets the appropriate type'); $t->is($b->getLexeme(0)->getPosition(), 4, '->commit() sets the appropriate position'); for ($x = 0; $x < 3; $x++) { $b->addToLexeme($b->getCharacter()); $b->next(); } $b->setType('baz'); $b->commit(); $t->is($b->next(), 'p', '->next() returns the next character.'); for ($x = 0; $x < 4; $x++) { $b->addToLexeme($b->getCharacter()); $b->next(); }