|
@@ 17-23 (lines=7) @@
|
| 14 |
|
use Vlaswinkel\Lua\LuaTokenStream; |
| 15 |
|
|
| 16 |
|
class LuaTokenStreamTest extends \PHPUnit_Framework_TestCase { |
| 17 |
|
public function testDoubleQuotedString() { |
| 18 |
|
$obj = new LuaTokenStream(new LuaInputStream('"foo"')); |
| 19 |
|
|
| 20 |
|
$token = $obj->next(); |
| 21 |
|
$this->assertEquals(LuaToken::TYPE_STRING, $token->getType()); |
| 22 |
|
$this->assertEquals("foo", $token->getValue()); |
| 23 |
|
} |
| 24 |
|
|
| 25 |
|
public function testSingleQuotedString() { |
| 26 |
|
$obj = new LuaTokenStream(new LuaInputStream("'foo'")); |
|
@@ 25-31 (lines=7) @@
|
| 22 |
|
$this->assertEquals("foo", $token->getValue()); |
| 23 |
|
} |
| 24 |
|
|
| 25 |
|
public function testSingleQuotedString() { |
| 26 |
|
$obj = new LuaTokenStream(new LuaInputStream("'foo'")); |
| 27 |
|
|
| 28 |
|
$token = $obj->next(); |
| 29 |
|
$this->assertEquals(LuaToken::TYPE_STRING, $token->getType()); |
| 30 |
|
$this->assertEquals("foo", $token->getValue()); |
| 31 |
|
} |
| 32 |
|
|
| 33 |
|
public function testNumberInt() { |
| 34 |
|
$obj = new LuaTokenStream(new LuaInputStream("1337")); |
|
@@ 33-39 (lines=7) @@
|
| 30 |
|
$this->assertEquals("foo", $token->getValue()); |
| 31 |
|
} |
| 32 |
|
|
| 33 |
|
public function testNumberInt() { |
| 34 |
|
$obj = new LuaTokenStream(new LuaInputStream("1337")); |
| 35 |
|
|
| 36 |
|
$token = $obj->next(); |
| 37 |
|
$this->assertEquals(LuaToken::TYPE_NUMBER, $token->getType()); |
| 38 |
|
$this->assertEquals(1337, $token->getValue()); |
| 39 |
|
} |
| 40 |
|
|
| 41 |
|
public function testNumberFloat() { |
| 42 |
|
$obj = new LuaTokenStream(new LuaInputStream("13.37")); |
|
@@ 41-47 (lines=7) @@
|
| 38 |
|
$this->assertEquals(1337, $token->getValue()); |
| 39 |
|
} |
| 40 |
|
|
| 41 |
|
public function testNumberFloat() { |
| 42 |
|
$obj = new LuaTokenStream(new LuaInputStream("13.37")); |
| 43 |
|
|
| 44 |
|
$token = $obj->next(); |
| 45 |
|
$this->assertEquals(LuaToken::TYPE_NUMBER, $token->getType()); |
| 46 |
|
$this->assertEquals(13.37, $token->getValue()); |
| 47 |
|
} |
| 48 |
|
|
| 49 |
|
public function testPunctuation() { |
| 50 |
|
foreach ([',', '{', '}', '=', '[', ']'] as $punc) { |
|
@@ 59-65 (lines=7) @@
|
| 56 |
|
} |
| 57 |
|
} |
| 58 |
|
|
| 59 |
|
public function testIdentifier() { |
| 60 |
|
$obj = new LuaTokenStream(new LuaInputStream("foo")); |
| 61 |
|
|
| 62 |
|
$token = $obj->next(); |
| 63 |
|
$this->assertEquals(LuaToken::TYPE_IDENTIFIER, $token->getType()); |
| 64 |
|
$this->assertEquals('foo', $token->getValue()); |
| 65 |
|
} |
| 66 |
|
|
| 67 |
|
public function testKeyword() { |
| 68 |
|
foreach (Lua::$luaKeywords as $keyword) { |