xref: /dokuwiki/_test/tests/Parsing/Lexer/StateStackTest.php (revision 504c13e8df88563c11b3720b317991bc38835a35)
1*504c13e8SAndreas Gohr<?php
2*504c13e8SAndreas Gohr
3*504c13e8SAndreas Gohrnamespace dokuwiki\test\Parsing\Lexer;
4*504c13e8SAndreas Gohr
5*504c13e8SAndreas Gohruse dokuwiki\Parsing\Lexer\StateStack;
6*504c13e8SAndreas Gohr
7*504c13e8SAndreas Gohrclass StateStackTest extends \DokuWikiTest
8*504c13e8SAndreas Gohr{
9*504c13e8SAndreas Gohr    function testStartState()
10*504c13e8SAndreas Gohr    {
11*504c13e8SAndreas Gohr        $stack = new StateStack("one");
12*504c13e8SAndreas Gohr        $this->assertEquals("one", $stack->getCurrent());
13*504c13e8SAndreas Gohr    }
14*504c13e8SAndreas Gohr
15*504c13e8SAndreas Gohr    function testExhaustion()
16*504c13e8SAndreas Gohr    {
17*504c13e8SAndreas Gohr        $stack = new StateStack("one");
18*504c13e8SAndreas Gohr        $this->assertFalse($stack->leave());
19*504c13e8SAndreas Gohr    }
20*504c13e8SAndreas Gohr
21*504c13e8SAndreas Gohr    function testStateMoves()
22*504c13e8SAndreas Gohr    {
23*504c13e8SAndreas Gohr        $stack = new StateStack("one");
24*504c13e8SAndreas Gohr        $stack->enter("two");
25*504c13e8SAndreas Gohr        $this->assertEquals("two", $stack->getCurrent());
26*504c13e8SAndreas Gohr        $stack->enter("three");
27*504c13e8SAndreas Gohr        $this->assertEquals("three", $stack->getCurrent());
28*504c13e8SAndreas Gohr        $this->assertTrue($stack->leave());
29*504c13e8SAndreas Gohr        $this->assertEquals("two", $stack->getCurrent());
30*504c13e8SAndreas Gohr        $stack->enter("third");
31*504c13e8SAndreas Gohr        $this->assertEquals("third", $stack->getCurrent());
32*504c13e8SAndreas Gohr        $this->assertTrue($stack->leave());
33*504c13e8SAndreas Gohr        $this->assertTrue($stack->leave());
34*504c13e8SAndreas Gohr        $this->assertEquals("one", $stack->getCurrent());
35*504c13e8SAndreas Gohr    }
36*504c13e8SAndreas Gohr}
37