LuaInputStreamTest::testSimpleNext()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
c 0
b 0
f 0
rs 10
nc 1
cc 1
eloc 3
nop 0
1
<?php
2
3
namespace Vlaswinkel\Lua\Tests;
4
5
use Vlaswinkel\Lua\InputStream;
6
7
/**
8
 * Class LuaInputStreamTest
9
 *
10
 * @author  Koen Vlaswinkel <[email protected]>
11
 * @package Vlaswinkel\Lua\Tests
12
 */
13
class LuaInputStreamTest extends \PHPUnit_Framework_TestCase {
14
    public function testSimpleNext() {
15
        $obj = new InputStream("a");
16
        $this->assertEquals("a", $obj->next());
17
    }
18
19 View Code Duplication
    public function testMultipleLines() {
20
        $obj = new InputStream("a\nb\n");
21
22
        $this->assertEquals("a", $obj->next());
23
        $this->assertEquals("\n", $obj->next());
24
        $this->assertEquals("b", $obj->next());
25
        $this->assertEquals("\n", $obj->next());
26
        $this->assertTrue($obj->eof());
27
    }
28
29
    /**
30
     * @expectedException \Vlaswinkel\Lua\ParseException
31
     * @expectedExceptionMessage Simple error (1:1)
32
     */
33
    public function testSimpleError() {
34
        $obj = new InputStream("a");
35
        $this->assertEquals("a", $obj->next());
36
37
        $obj->error("Simple error");
38
    }
39
40
    /**
41
     * @expectedException \Vlaswinkel\Lua\ParseException
42
     * @expectedExceptionMessage Other error (2:1)
43
     */
44 View Code Duplication
    public function testMultipleLineError() {
45
        $obj = new InputStream("a\nb");
46
        $this->assertEquals("a", $obj->next());
47
        $this->assertEquals("\n", $obj->next());
48
        $this->assertEquals("b", $obj->next());
49
50
        $obj->error("Other error");
51
    }
52
53
    /**
54
     * @expectedException \Vlaswinkel\Lua\ParseException
55
     * @expectedExceptionMessage This error (1:2)
56
     */
57 View Code Duplication
    public function testMultipleColumnError() {
58
        $obj = new InputStream("ab");
59
        $this->assertEquals("a", $obj->next());
60
        $this->assertEquals("b", $obj->next());
61
62
        $obj->error("This error");
63
    }
64
65
    /**
66
     * @expectedException \Vlaswinkel\Lua\ParseException
67
     * @expectedExceptionMessage Complex error (2:2)
68
     */
69 View Code Duplication
    public function testMultipleLineAndColumnError() {
70
        $obj = new InputStream("ab\nab\n");
71
        $this->assertEquals("a", $obj->next());
72
        $this->assertEquals("b", $obj->next());
73
        $this->assertEquals("\n", $obj->next());
74
75
        $this->assertEquals("a", $obj->next());
76
        $this->assertEquals("b", $obj->next());
77
78
        $obj->error("Complex error");
79
    }
80
}