|
@@ 20-28 (lines=9) @@
|
| 17 |
|
* @package Vlaswinkel\Lua\Tests |
| 18 |
|
*/ |
| 19 |
|
class LuaParserTest extends \PHPUnit_Framework_TestCase { |
| 20 |
|
public function testString() { |
| 21 |
|
$parser = new Parser(new TokenStream(new InputStream('"foo"'))); |
| 22 |
|
|
| 23 |
|
$node = $parser->parse(); |
| 24 |
|
|
| 25 |
|
$this->assertEquals(StringASTNode::NAME, $node->getName()); |
| 26 |
|
$this->assertInstanceOf(StringASTNode::class, $node); |
| 27 |
|
$this->assertEquals("foo", $node->getValue()); |
| 28 |
|
} |
| 29 |
|
|
| 30 |
|
public function testStringWithSpaces() { |
| 31 |
|
$parser = new Parser(new TokenStream(new InputStream('"foo bar."'))); |
|
@@ 30-38 (lines=9) @@
|
| 27 |
|
$this->assertEquals("foo", $node->getValue()); |
| 28 |
|
} |
| 29 |
|
|
| 30 |
|
public function testStringWithSpaces() { |
| 31 |
|
$parser = new Parser(new TokenStream(new InputStream('"foo bar."'))); |
| 32 |
|
|
| 33 |
|
$node = $parser->parse(); |
| 34 |
|
|
| 35 |
|
$this->assertEquals(StringASTNode::NAME, $node->getName()); |
| 36 |
|
$this->assertInstanceOf(StringASTNode::class, $node); |
| 37 |
|
$this->assertEquals("foo bar.", $node->getValue()); |
| 38 |
|
} |
| 39 |
|
|
| 40 |
|
public function testAlternateString() { |
| 41 |
|
$parser = new Parser(new TokenStream(new InputStream('[[foo]]'))); |
|
@@ 40-48 (lines=9) @@
|
| 37 |
|
$this->assertEquals("foo bar.", $node->getValue()); |
| 38 |
|
} |
| 39 |
|
|
| 40 |
|
public function testAlternateString() { |
| 41 |
|
$parser = new Parser(new TokenStream(new InputStream('[[foo]]'))); |
| 42 |
|
|
| 43 |
|
$node = $parser->parse(); |
| 44 |
|
|
| 45 |
|
$this->assertEquals(StringASTNode::NAME, $node->getName()); |
| 46 |
|
$this->assertInstanceOf(StringASTNode::class, $node); |
| 47 |
|
$this->assertEquals("foo", $node->getValue()); |
| 48 |
|
} |
| 49 |
|
|
| 50 |
|
// https://github.com/koesie10/LuaSerializer/issues/1 |
| 51 |
|
public function testAlternateStringWithSpaces() { |
|
@@ 51-59 (lines=9) @@
|
| 48 |
|
} |
| 49 |
|
|
| 50 |
|
// https://github.com/koesie10/LuaSerializer/issues/1 |
| 51 |
|
public function testAlternateStringWithSpaces() { |
| 52 |
|
$parser = new Parser(new TokenStream(new InputStream('[[foo bar.]]'))); |
| 53 |
|
|
| 54 |
|
$node = $parser->parse(); |
| 55 |
|
|
| 56 |
|
$this->assertEquals(StringASTNode::NAME, $node->getName()); |
| 57 |
|
$this->assertInstanceOf(StringASTNode::class, $node); |
| 58 |
|
$this->assertEquals("foo bar.", $node->getValue()); |
| 59 |
|
} |
| 60 |
|
|
| 61 |
|
public function testNumber() { |
| 62 |
|
$parser = new Parser(new TokenStream(new InputStream('1337'))); |
|
@@ 61-69 (lines=9) @@
|
| 58 |
|
$this->assertEquals("foo bar.", $node->getValue()); |
| 59 |
|
} |
| 60 |
|
|
| 61 |
|
public function testNumber() { |
| 62 |
|
$parser = new Parser(new TokenStream(new InputStream('1337'))); |
| 63 |
|
|
| 64 |
|
$node = $parser->parse(); |
| 65 |
|
|
| 66 |
|
$this->assertEquals(NumberASTNode::NAME, $node->getName()); |
| 67 |
|
$this->assertInstanceOf(NumberASTNode::class, $node); |
| 68 |
|
$this->assertEquals(1337, $node->getValue()); |
| 69 |
|
} |
| 70 |
|
|
| 71 |
|
public function testNil() { |
| 72 |
|
$parser = new Parser(new TokenStream(new InputStream('nil'))); |
|
@@ 71-78 (lines=8) @@
|
| 68 |
|
$this->assertEquals(1337, $node->getValue()); |
| 69 |
|
} |
| 70 |
|
|
| 71 |
|
public function testNil() { |
| 72 |
|
$parser = new Parser(new TokenStream(new InputStream('nil'))); |
| 73 |
|
|
| 74 |
|
$node = $parser->parse(); |
| 75 |
|
|
| 76 |
|
$this->assertEquals(NilASTNode::NAME, $node->getName()); |
| 77 |
|
$this->assertInstanceOf(NilASTNode::class, $node); |
| 78 |
|
} |
| 79 |
|
|
| 80 |
|
public function testTableKey() { |
| 81 |
|
$parser = new Parser(new TokenStream(new InputStream('["test"]'))); |
|
@@ 80-88 (lines=9) @@
|
| 77 |
|
$this->assertInstanceOf(NilASTNode::class, $node); |
| 78 |
|
} |
| 79 |
|
|
| 80 |
|
public function testTableKey() { |
| 81 |
|
$parser = new Parser(new TokenStream(new InputStream('["test"]'))); |
| 82 |
|
|
| 83 |
|
$node = $parser->parse(); |
| 84 |
|
|
| 85 |
|
$this->assertEquals(StringASTNode::NAME, $node->getName()); |
| 86 |
|
$this->assertInstanceOf(StringASTNode::class, $node); |
| 87 |
|
$this->assertEquals("test", $node->getValue()); |
| 88 |
|
} |
| 89 |
|
|
| 90 |
|
public function testSimpleTable() { |
| 91 |
|
$parser = new Parser( |