Code Duplication    Length = 28-28 lines in 2 locations

tests/LuaParserTest.php 2 locations

@@ 90-117 (lines=28) @@
87
        $this->assertEquals("test", $node->getValue());
88
    }
89
90
    public function testSimpleTable() {
91
        $parser = new Parser(
92
            new TokenStream(
93
                new InputStream(
94
                    '{
95
            foo = "bar"
96
        }'
97
                )
98
            )
99
        );
100
101
        $node = $parser->parse();
102
103
        $this->assertEquals(TableASTNode::NAME, $node->getName());
104
        $this->assertInstanceOf(TableASTNode::class, $node);
105
106
        $this->assertCount(1, $node->getEntries());
107
        $entry = $node->getEntries()[0];
108
109
        $this->assertTrue($entry->hasKey());
110
        $this->assertEquals(StringASTNode::NAME, $entry->getKey()->getName());
111
        $this->assertInstanceOf(StringASTNode::class, $entry->getKey());
112
        $this->assertEquals("foo", $entry->getKey()->getValue());
113
114
        $this->assertEquals(StringASTNode::NAME, $entry->getValue()->getName());
115
        $this->assertInstanceOf(StringASTNode::class, $entry->getValue());
116
        $this->assertEquals("bar", $entry->getValue()->getValue());
117
    }
118
119
    public function testNestedTable() {
120
        $parser = new Parser(
@@ 180-207 (lines=28) @@
177
        $this->assertEquals("bar", $nestedNestedEntry2->getValue()->getValue());
178
    }
179
180
    public function testTableWithNestedAlternateStrings() {
181
        $parser = new Parser(
182
            new TokenStream(
183
                new InputStream(
184
                    '{
185
            foo = [[bar]]
186
        }'
187
                )
188
            )
189
        );
190
191
        $node = $parser->parse();
192
193
        $this->assertEquals(TableASTNode::NAME, $node->getName());
194
        $this->assertInstanceOf(TableASTNode::class, $node);
195
196
        $this->assertCount(1, $node->getEntries());
197
        $entry = $node->getEntries()[0];
198
199
        $this->assertTrue($entry->hasKey());
200
        $this->assertEquals(StringASTNode::NAME, $entry->getKey()->getName());
201
        $this->assertInstanceOf(StringASTNode::class, $entry->getKey());
202
        $this->assertEquals("foo", $entry->getKey()->getValue());
203
204
        $this->assertEquals(StringASTNode::NAME, $entry->getValue()->getName());
205
        $this->assertInstanceOf(StringASTNode::class, $entry->getValue());
206
        $this->assertEquals("bar", $entry->getValue()->getValue());
207
    }
208
209
    /**
210
     * @expectedException \Vlaswinkel\Lua\ParseException