From 4a0b564ef56575628ba87c7f601bdcddcbeacddb Mon Sep 17 00:00:00 2001 From: Dominik Eckelmann Date: Fri, 6 Apr 2012 23:54:26 +0200 Subject: finished transformation of lexer.test.php --- _testing/unittests/inc/parser/lexer.test.php | 531 +++++++++++++++++++++++ _testing/unittests/inc/parser/lexer.todo.php | 616 --------------------------- 2 files changed, 531 insertions(+), 616 deletions(-) create mode 100644 _testing/unittests/inc/parser/lexer.test.php delete mode 100644 _testing/unittests/inc/parser/lexer.todo.php (limited to '_testing/unittests/inc/parser') diff --git a/_testing/unittests/inc/parser/lexer.test.php b/_testing/unittests/inc/parser/lexer.test.php new file mode 100644 index 000000000..4fccc6688 --- /dev/null +++ b/_testing/unittests/inc/parser/lexer.test.php @@ -0,0 +1,531 @@ +assertFalse($regex->match("Hello", $match)); + $this->assertEquals($match, ""); + } + function testNoSubject() { + $regex = new Doku_LexerParallelRegex(false); + $regex->addPattern(".*"); + $this->assertTrue($regex->match("", $match)); + $this->assertEquals($match, ""); + } + function testMatchAll() { + $regex = new Doku_LexerParallelRegex(false); + $regex->addPattern(".*"); + $this->assertTrue($regex->match("Hello", $match)); + $this->assertEquals($match, "Hello"); + } + function testCaseSensitive() { + $regex = new Doku_LexerParallelRegex(true); + $regex->addPattern("abc"); + $this->assertTrue($regex->match("abcdef", $match)); + $this->assertEquals($match, "abc"); + $this->assertTrue($regex->match("AAABCabcdef", $match)); + $this->assertEquals($match, "abc"); + } + function testCaseInsensitive() { + $regex = new Doku_LexerParallelRegex(false); + $regex->addPattern("abc"); + $this->assertTrue($regex->match("abcdef", $match)); + $this->assertEquals($match, "abc"); + $this->assertTrue($regex->match("AAABCabcdef", $match)); + $this->assertEquals($match, "ABC"); + } + function testMatchMultiple() { + $regex = new Doku_LexerParallelRegex(true); + $regex->addPattern("abc"); + $regex->addPattern("ABC"); + $this->assertTrue($regex->match("abcdef", $match)); + $this->assertEquals($match, "abc"); + $this->assertTrue($regex->match("AAABCabcdef", $match)); + $this->assertEquals($match, "ABC"); + $this->assertFalse($regex->match("Hello", $match)); + } + function testPatternLabels() { + $regex = new Doku_LexerParallelRegex(false); + $regex->addPattern("abc", "letter"); + $regex->addPattern("123", "number"); + $this->assertEquals($regex->match("abcdef", $match), "letter"); + $this->assertEquals($match, "abc"); + $this->assertEquals($regex->match("0123456789", $match), "number"); + $this->assertEquals($match, "123"); + } + function testMatchMultipleWithLookaheadNot() { + $regex = new Doku_LexerParallelRegex(true); + $regex->addPattern("abc"); + $regex->addPattern("ABC"); + $regex->addPattern("a(?!\n).{1}"); + $this->assertTrue($regex->match("abcdef", $match)); + $this->assertEquals($match, "abc"); + $this->assertTrue($regex->match("AAABCabcdef", $match)); + $this->assertEquals($match, "ABC"); + $this->assertTrue($regex->match("a\nab", $match)); + $this->assertEquals($match, "ab"); + $this->assertFalse($regex->match("Hello", $match)); + } + function testMatchSetOptionCaseless() { + $regex = new Doku_LexerParallelRegex(true); + $regex->addPattern("a(?i)b(?i)c"); + $this->assertTrue($regex->match("aBc", $match)); + $this->assertEquals($match, "aBc"); + } + function testMatchSetOptionUngreedy() { + $regex = new Doku_LexerParallelRegex(true); + $regex->addPattern("(?U)\w+"); + $this->assertTrue($regex->match("aaaaaa", $match)); + $this->assertEquals($match, "a"); + } + function testMatchLookaheadEqual() { + $regex = new Doku_LexerParallelRegex(true); + $regex->addPattern("\w(?=c)"); + $this->assertTrue($regex->match("xbyczd", $match)); + $this->assertEquals($match, "y"); + } + function testMatchLookaheadNot() { + $regex = new Doku_LexerParallelRegex(true); + $regex->addPattern("\w(?!b|c)"); + $this->assertTrue($regex->match("xbyczd", $match)); + $this->assertEquals($match, "b"); + } + function testMatchLookbehindEqual() { + $regex = new Doku_LexerParallelRegex(true); + $regex->addPattern("(?<=c)\w"); + $this->assertTrue($regex->match("xbyczd", $match)); + $this->assertEquals($match, "z"); + } + function testMatchLookbehindNot() { + $regex = new Doku_LexerParallelRegex(true); + $regex->addPattern("(?assertTrue($regex->match("xbyczd", $match)); + $this->assertEquals($match, "c"); + } +} + + +class TestOfLexerStateStack extends PHPUnit_Framework_TestCase { + function testStartState() { + $stack = new Doku_LexerStateStack("one"); + $this->assertEquals($stack->getCurrent(), "one"); + } + function testExhaustion() { + $stack = new Doku_LexerStateStack("one"); + $this->assertFalse($stack->leave()); + } + function testStateMoves() { + $stack = new Doku_LexerStateStack("one"); + $stack->enter("two"); + $this->assertEquals($stack->getCurrent(), "two"); + $stack->enter("three"); + $this->assertEquals($stack->getCurrent(), "three"); + $this->assertTrue($stack->leave()); + $this->assertEquals($stack->getCurrent(), "two"); + $stack->enter("third"); + $this->assertEquals($stack->getCurrent(), "third"); + $this->assertTrue($stack->leave()); + $this->assertTrue($stack->leave()); + $this->assertEquals($stack->getCurrent(), "one"); + } +} + +class TestParser { + function TestParser() { + } + function accept() { + } + function a() { + } + function b() { + } +} + +class TestOfLexer extends PHPUnit_Framework_TestCase { + function testNoPatterns() { + $handler = $this->getMock('TestParser'); + $handler->expects($this->never())->method('accept'); + $lexer = new Doku_Lexer($handler); + $this->assertFalse($lexer->parse("abcdef")); + } + function testEmptyPage() { + $handler = $this->getMock('TestParser'); + $handler->expects($this->never())->method('accept'); + $lexer = new Doku_Lexer($handler); + $lexer->addPattern("a+"); + $this->assertTrue($lexer->parse("")); + } + function testSinglePattern() { + $handler = $this->getMock('TestParser'); + $handler->expects($this->at(0))->method('accept') + ->with("aaa", DOKU_LEXER_MATCHED, 0)->will($this->returnValue(true)); + $handler->expects($this->at(1))->method('accept') + ->with("x", DOKU_LEXER_UNMATCHED, 3)->will($this->returnValue(true)); + $handler->expects($this->at(2))->method('accept') + ->with("a", DOKU_LEXER_MATCHED, 4)->will($this->returnValue(true)); + $handler->expects($this->at(3))->method('accept') + ->with("yyy", DOKU_LEXER_UNMATCHED, 5)->will($this->returnValue(true)); + $handler->expects($this->at(4))->method('accept') + ->with("a", DOKU_LEXER_MATCHED, 8)->will($this->returnValue(true)); + $handler->expects($this->at(5))->method('accept') + ->with("x", DOKU_LEXER_UNMATCHED, 9)->will($this->returnValue(true)); + $handler->expects($this->at(6))->method('accept') + ->with("aaa", DOKU_LEXER_MATCHED, 10)->will($this->returnValue(true)); + $handler->expects($this->at(7))->method('accept') + ->with("z", DOKU_LEXER_UNMATCHED, 13)->will($this->returnValue(true)); + + $lexer = new Doku_Lexer($handler); + $lexer->addPattern("a+"); + $this->assertTrue($lexer->parse("aaaxayyyaxaaaz")); + } + function testMultiplePattern() { + $handler = $this->getMock('TestParser', array('accept')); + $target = array("a", "b", "a", "bb", "x", "b", "a", "xxxxxx", "a", "x"); + $positions = array(0, 1, 2, 3, 5, 6, 7, 8, 14, 15); + for ($i = 0; $i < count($target); $i++) { + $handler->expects($this->at($i))->method('accept') + ->with($target[$i], $this->anything(), $positions[$i])->will($this->returnValue(true)); + } + $lexer = new Doku_Lexer($handler); + $lexer->addPattern("a+"); + $lexer->addPattern("b+"); + $this->assertTrue($lexer->parse("ababbxbaxxxxxxax")); + } +} + +class TestOfLexerModes extends PHPUnit_Framework_TestCase { + function testIsolatedPattern() { + $handler = $this->getMock('TestParser'); + $handler->expects($this->at(0))->method('a') + ->with("a", DOKU_LEXER_MATCHED,0)->will($this->returnValue(true)); + $handler->expects($this->at(1))->method('a') + ->with("b", DOKU_LEXER_UNMATCHED,1)->will($this->returnValue(true)); + $handler->expects($this->at(2))->method('a') + ->with("aa", DOKU_LEXER_MATCHED,2)->will($this->returnValue(true)); + $handler->expects($this->at(3))->method('a') + ->with("bxb", DOKU_LEXER_UNMATCHED,4)->will($this->returnValue(true)); + $handler->expects($this->at(4))->method('a') + ->with("aaa", DOKU_LEXER_MATCHED,7)->will($this->returnValue(true)); + $handler->expects($this->at(5))->method('a') + ->with("x", DOKU_LEXER_UNMATCHED,10)->will($this->returnValue(true)); + $handler->expects($this->at(6))->method('a') + ->with("aaaa", DOKU_LEXER_MATCHED,11)->will($this->returnValue(true)); + $handler->expects($this->at(7))->method('a') + ->with("x", DOKU_LEXER_UNMATCHED,15)->will($this->returnValue(true)); + $lexer = new Doku_Lexer($handler, "a"); + $lexer->addPattern("a+", "a"); + $lexer->addPattern("b+", "b"); + $this->assertTrue($lexer->parse("abaabxbaaaxaaaax")); + } + function testModeChange() { + $handler = $this->getMock('TestParser'); + $handler->expects($this->at(0))->method('a') + ->with("a", DOKU_LEXER_MATCHED,0)->will($this->returnValue(true)); + $handler->expects($this->at(1))->method('a') + ->with("b", DOKU_LEXER_UNMATCHED,1)->will($this->returnValue(true)); + $handler->expects($this->at(2))->method('a') + ->with("aa", DOKU_LEXER_MATCHED,2)->will($this->returnValue(true)); + $handler->expects($this->at(3))->method('a') + ->with("b", DOKU_LEXER_UNMATCHED,4)->will($this->returnValue(true)); + $handler->expects($this->at(4))->method('a') + ->with("aaa", DOKU_LEXER_MATCHED,5)->will($this->returnValue(true)); + $handler->expects($this->at(5))->method('b') + ->with(":", DOKU_LEXER_ENTER,8)->will($this->returnValue(true)); + $handler->expects($this->at(6))->method('b') + ->with("a", DOKU_LEXER_UNMATCHED,9)->will($this->returnValue(true)); + $handler->expects($this->at(7))->method('b') + ->with("b", DOKU_LEXER_MATCHED, 10)->will($this->returnValue(true)); + $handler->expects($this->at(8))->method('b') + ->with("a", DOKU_LEXER_UNMATCHED,11)->will($this->returnValue(true)); + $handler->expects($this->at(9))->method('b') + ->with("bb", DOKU_LEXER_MATCHED,12)->will($this->returnValue(true)); + $handler->expects($this->at(10))->method('b') + ->with("a", DOKU_LEXER_UNMATCHED,14)->will($this->returnValue(true)); + $handler->expects($this->at(11))->method('b') + ->with("bbb", DOKU_LEXER_MATCHED,15)->will($this->returnValue(true)); + $handler->expects($this->at(12))->method('b') + ->with("a", DOKU_LEXER_UNMATCHED,18)->will($this->returnValue(true)); + + $lexer = new Doku_Lexer($handler, "a"); + $lexer->addPattern("a+", "a"); + $lexer->addEntryPattern(":", "a", "b"); + $lexer->addPattern("b+", "b"); + $this->assertTrue($lexer->parse("abaabaaa:ababbabbba")); + } + function testNesting() { + $handler = $this->getMock('TestParser'); + $handler->expects($this->at(0))->method('a') + ->with("aa", DOKU_LEXER_MATCHED,0)->will($this->returnValue(true)); + $handler->expects($this->at(1))->method('a') + ->with("b", DOKU_LEXER_UNMATCHED,2)->will($this->returnValue(true)); + $handler->expects($this->at(2))->method('a') + ->with("aa", DOKU_LEXER_MATCHED,3)->will($this->returnValue(true)); + $handler->expects($this->at(3))->method('a') + ->with("b", DOKU_LEXER_UNMATCHED,5)->will($this->returnValue(true)); + $handler->expects($this->at(4))->method('b') + ->with("(", DOKU_LEXER_ENTER,6)->will($this->returnValue(true)); + $handler->expects($this->at(5))->method('b') + ->with("bb", DOKU_LEXER_MATCHED,7)->will($this->returnValue(true)); + $handler->expects($this->at(6))->method('b') + ->with("a", DOKU_LEXER_UNMATCHED,9)->will($this->returnValue(true)); + $handler->expects($this->at(7))->method('b') + ->with("bb", DOKU_LEXER_MATCHED,10)->will($this->returnValue(true)); + $handler->expects($this->at(8))->method('b') + ->with(")", DOKU_LEXER_EXIT,12)->will($this->returnValue(true)); + $handler->expects($this->at(9))->method('a') + ->with("aa", DOKU_LEXER_MATCHED,13)->will($this->returnValue(true)); + $handler->expects($this->at(10))->method('a') + ->with("b", DOKU_LEXER_UNMATCHED,15)->will($this->returnValue(true)); + + + $lexer = new Doku_Lexer($handler, "a"); + $lexer->addPattern("a+", "a"); + $lexer->addEntryPattern("(", "a", "b"); + $lexer->addPattern("b+", "b"); + $lexer->addExitPattern(")", "b"); + $this->assertTrue($lexer->parse("aabaab(bbabb)aab")); + } + function testSingular() { + $handler = $this->getMock('TestParser'); + $handler->expects($this->at(0))->method('a') + ->with("aa", DOKU_LEXER_MATCHED,0)->will($this->returnValue(true)); + $handler->expects($this->at(1))->method('b') + ->with("b", DOKU_LEXER_SPECIAL,2)->will($this->returnValue(true)); + $handler->expects($this->at(2))->method('a') + ->with("aa", DOKU_LEXER_MATCHED,3)->will($this->returnValue(true)); + $handler->expects($this->at(3))->method('a') + ->with("xx", DOKU_LEXER_UNMATCHED,5)->will($this->returnValue(true)); + $handler->expects($this->at(4))->method('b') + ->with("bbb", DOKU_LEXER_SPECIAL,7)->will($this->returnValue(true)); + $handler->expects($this->at(5))->method('a') + ->with("xx", DOKU_LEXER_UNMATCHED,10)->will($this->returnValue(true)); + $lexer = new Doku_Lexer($handler, "a"); + $lexer->addPattern("a+", "a"); + $lexer->addSpecialPattern("b+", "a", "b"); + $this->assertTrue($lexer->parse("aabaaxxbbbxx")); + } + function testUnwindTooFar() { + $handler = $this->getMock('TestParser'); + $handler->expects($this->at(0))->method('a') + ->with("aa", DOKU_LEXER_MATCHED,0)->will($this->returnValue(true)); + $handler->expects($this->at(1))->method('a') + ->with(")", DOKU_LEXER_EXIT,2)->will($this->returnValue(true)); + + $lexer = new Doku_Lexer($handler, "a"); + $lexer->addPattern("a+", "a"); + $lexer->addExitPattern(")", "a"); + $this->assertFalse($lexer->parse("aa)aa")); + } +} + +class TestOfLexerHandlers extends PHPUnit_Framework_TestCase { + function testModeMapping() { + $handler = $this->getMock('TestParser'); + $handler->expects($this->at(0))->method('a') + ->with("aa", DOKU_LEXER_MATCHED,0)->will($this->returnValue(true)); + $handler->expects($this->at(1))->method('a') + ->with("(", DOKU_LEXER_ENTER,2)->will($this->returnValue(true)); + $handler->expects($this->at(2))->method('a') + ->with("bb", DOKU_LEXER_MATCHED,3)->will($this->returnValue(true)); + $handler->expects($this->at(3))->method('a') + ->with("a", DOKU_LEXER_UNMATCHED,5)->will($this->returnValue(true)); + $handler->expects($this->at(4))->method('a') + ->with("bb", DOKU_LEXER_MATCHED,6)->will($this->returnValue(true)); + $handler->expects($this->at(5))->method('a') + ->with(")", DOKU_LEXER_EXIT,8)->will($this->returnValue(true)); + $handler->expects($this->at(6))->method('a') + ->with("b", DOKU_LEXER_UNMATCHED,9)->will($this->returnValue(true)); + + $lexer = new Doku_Lexer($handler, "mode_a"); + $lexer->addPattern("a+", "mode_a"); + $lexer->addEntryPattern("(", "mode_a", "mode_b"); + $lexer->addPattern("b+", "mode_b"); + $lexer->addExitPattern(")", "mode_b"); + $lexer->mapHandler("mode_a", "a"); + $lexer->mapHandler("mode_b", "a"); + $this->assertTrue($lexer->parse("aa(bbabb)b")); + } +} + +class TestParserByteIndex { + + function TestParserByteIndex() {} + + function ignore() {} + + function caught() {} +} + +class TestOfLexerByteIndices extends PHPUnit_Framework_TestCase { + + function testIndex() { + $doc = "aaabcdeee"; + + $handler = $this->getMock('TestParserByteIndex'); + $handler->expects($this->any())->method('ignore')->will($this->returnValue(true)); + $handler->expects($this->at(1))->method('caught') + ->with("", DOKU_LEXER_ENTER, strpos($doc,''))->will($this->returnValue(true)); + $handler->expects($this->at(2))->method('caught') + ->with("b", DOKU_LEXER_SPECIAL, strpos($doc,'b'))->will($this->returnValue(true)); + $handler->expects($this->at(3))->method('caught') + ->with("c", DOKU_LEXER_MATCHED, strpos($doc,'c'))->will($this->returnValue(true)); + $handler->expects($this->at(4))->method('caught') + ->with("d", DOKU_LEXER_UNMATCHED, strpos($doc,'d'))->will($this->returnValue(true)); + $handler->expects($this->at(5))->method('caught') + ->with("", DOKU_LEXER_EXIT, strpos($doc,''))->will($this->returnValue(true)); + + $lexer = new Doku_Lexer($handler, "ignore"); + $lexer->addEntryPattern("", "ignore", "caught"); + $lexer->addExitPattern("", "caught"); + $lexer->addSpecialPattern('b','caught','special'); + $lexer->mapHandler('special','caught'); + $lexer->addPattern('c','caught'); + + $this->assertTrue($lexer->parse($doc)); + } + + function testIndexLookaheadEqual() { + $doc = "aaabcdeee"; + + $handler = $this->getMock('TestParserByteIndex'); + $handler->expects($this->any())->method('ignore')->will($this->returnValue(true)); + $handler->expects($this->at(1))->method('caught') + ->with("", DOKU_LEXER_ENTER, strpos($doc,''))->will($this->returnValue(true)); + $handler->expects($this->at(2))->method('caught') + ->with("b", DOKU_LEXER_SPECIAL, strpos($doc,'b'))->will($this->returnValue(true)); + $handler->expects($this->at(3))->method('caught') + ->with("c", DOKU_LEXER_MATCHED, strpos($doc,'c'))->will($this->returnValue(true)); + $handler->expects($this->at(4))->method('caught') + ->with("d", DOKU_LEXER_UNMATCHED, strpos($doc,'d'))->will($this->returnValue(true)); + $handler->expects($this->at(5))->method('caught') + ->with("", DOKU_LEXER_EXIT, strpos($doc,''))->will($this->returnValue(true)); + + $lexer = new Doku_Lexer($handler, "ignore"); + $lexer->addEntryPattern('(?=.*)', "ignore", "caught"); + $lexer->addExitPattern("", "caught"); + $lexer->addSpecialPattern('b','caught','special'); + $lexer->mapHandler('special','caught'); + $lexer->addPattern('c','caught'); + + $this->assertTrue($lexer->parse($doc)); + } + + function testIndexLookaheadNotEqual() { + $doc = "aaabcdeee"; + + $handler = $this->getMock('TestParserByteIndex'); + $handler->expects($this->any())->method('ignore')->will($this->returnValue(true)); + $handler->expects($this->at(1))->method('caught') + ->with("", DOKU_LEXER_ENTER, strpos($doc,''))->will($this->returnValue(true)); + $handler->expects($this->at(2))->method('caught') + ->with("b", DOKU_LEXER_SPECIAL, strpos($doc,'b'))->will($this->returnValue(true)); + $handler->expects($this->at(3))->method('caught') + ->with("c", DOKU_LEXER_MATCHED, strpos($doc,'c'))->will($this->returnValue(true)); + $handler->expects($this->at(4))->method('caught') + ->with("d", DOKU_LEXER_UNMATCHED, strpos($doc,'d'))->will($this->returnValue(true)); + $handler->expects($this->at(5))->method('caught') + ->with("", DOKU_LEXER_EXIT, strpos($doc,''))->will($this->returnValue(true)); + + $lexer = new Doku_Lexer($handler, "ignore"); + $lexer->addEntryPattern('(?!foo)', "ignore", "caught"); + $lexer->addExitPattern("", "caught"); + $lexer->addSpecialPattern('b','caught','special'); + $lexer->mapHandler('special','caught'); + $lexer->addPattern('c','caught'); + + $this->assertTrue($lexer->parse($doc)); + } + + function testIndexLookbehindEqual() { + $doc = "aaabcdeee"; + + $handler = $this->getMock('TestParserByteIndex'); + $handler->expects($this->any())->method('ignore')->will($this->returnValue(true)); + $handler->expects($this->at(1))->method('caught') + ->with("", DOKU_LEXER_ENTER, strpos($doc,''))->will($this->returnValue(true)); + $handler->expects($this->at(2))->method('caught') + ->with("b", DOKU_LEXER_SPECIAL, strpos($doc,'b'))->will($this->returnValue(true)); + $handler->expects($this->at(3))->method('caught') + ->with("c", DOKU_LEXER_MATCHED, strpos($doc,'c'))->will($this->returnValue(true)); + $handler->expects($this->at(4))->method('caught') + ->with("d", DOKU_LEXER_UNMATCHED, strpos($doc,'d'))->will($this->returnValue(true)); + $handler->expects($this->at(5))->method('caught') + ->with("", DOKU_LEXER_EXIT, strpos($doc,''))->will($this->returnValue(true)); + + $lexer = new Doku_Lexer($handler, "ignore"); + $lexer->addEntryPattern('', "ignore", "caught"); + $lexer->addExitPattern("(?<=d)", "caught"); + $lexer->addSpecialPattern('b','caught','special'); + $lexer->mapHandler('special','caught'); + $lexer->addPattern('c','caught'); + + $this->assertTrue($lexer->parse($doc)); + } + + function testIndexLookbehindNotEqual() { + $doc = "aaabcdeee"; + + $handler = $this->getMock('TestParserByteIndex'); + $handler->expects($this->any())->method('ignore')->will($this->returnValue(true)); + $handler->expects($this->at(1))->method('caught') + ->with("", DOKU_LEXER_ENTER, strpos($doc,''))->will($this->returnValue(true)); + $handler->expects($this->at(2))->method('caught') + ->with("b", DOKU_LEXER_SPECIAL, strpos($doc,'b'))->will($this->returnValue(true)); + $handler->expects($this->at(3))->method('caught') + ->with("c", DOKU_LEXER_MATCHED, strpos($doc,'c'))->will($this->returnValue(true)); + $handler->expects($this->at(4))->method('caught') + ->with("d", DOKU_LEXER_UNMATCHED, strpos($doc,'d'))->will($this->returnValue(true)); + $handler->expects($this->at(5))->method('caught') + ->with("", DOKU_LEXER_EXIT, strpos($doc,''))->will($this->returnValue(true)); + + $lexer = new Doku_Lexer($handler, 'ignore'); + $lexer->addEntryPattern('', 'ignore', 'caught'); + $lexer->addExitPattern('(?', 'caught'); + $lexer->addSpecialPattern('b','caught','special'); + $lexer->mapHandler('special','caught'); + $lexer->addPattern('c','caught'); + + $this->assertTrue($lexer->parse($doc)); + } + + /** + * This test is primarily to ensure the correct match is chosen + * when there are non-captured elements in the pattern. + */ + function testIndexSelectCorrectMatch() { + $doc = "ALL FOOLS ARE FOO"; + $pattern = '\bFOO\b'; + + $handler = $this->getMock('TestParserByteIndex'); + $handler->expects($this->any())->method('ignore')->will($this->returnValue(true)); + + $matches = array(); + preg_match('/'.$pattern.'/',$doc,$matches,PREG_OFFSET_CAPTURE); + + $handler->expects($this->once())->method('caught') + ->with("FOO", DOKU_LEXER_SPECIAL, $matches[0][1])->will($this->returnValue(true)); + + $lexer = new Doku_Lexer($handler, "ignore"); + $lexer->addSpecialPattern($pattern,'ignore','caught'); + + $this->assertTrue($lexer->parse($doc)); + } + +} + +?> diff --git a/_testing/unittests/inc/parser/lexer.todo.php b/_testing/unittests/inc/parser/lexer.todo.php deleted file mode 100644 index 7d04c0902..000000000 --- a/_testing/unittests/inc/parser/lexer.todo.php +++ /dev/null @@ -1,616 +0,0 @@ -assertFalse($regex->match("Hello", $match)); - $this->assertEquals($match, ""); - } - function testNoSubject() { - $regex = new Doku_LexerParallelRegex(false); - $regex->addPattern(".*"); - $this->assertTrue($regex->match("", $match)); - $this->assertEquals($match, ""); - } - function testMatchAll() { - $regex = new Doku_LexerParallelRegex(false); - $regex->addPattern(".*"); - $this->assertTrue($regex->match("Hello", $match)); - $this->assertEquals($match, "Hello"); - } - function testCaseSensitive() { - $regex = new Doku_LexerParallelRegex(true); - $regex->addPattern("abc"); - $this->assertTrue($regex->match("abcdef", $match)); - $this->assertEquals($match, "abc"); - $this->assertTrue($regex->match("AAABCabcdef", $match)); - $this->assertEquals($match, "abc"); - } - function testCaseInsensitive() { - $regex = new Doku_LexerParallelRegex(false); - $regex->addPattern("abc"); - $this->assertTrue($regex->match("abcdef", $match)); - $this->assertEquals($match, "abc"); - $this->assertTrue($regex->match("AAABCabcdef", $match)); - $this->assertEquals($match, "ABC"); - } - function testMatchMultiple() { - $regex = new Doku_LexerParallelRegex(true); - $regex->addPattern("abc"); - $regex->addPattern("ABC"); - $this->assertTrue($regex->match("abcdef", $match)); - $this->assertEquals($match, "abc"); - $this->assertTrue($regex->match("AAABCabcdef", $match)); - $this->assertEquals($match, "ABC"); - $this->assertFalse($regex->match("Hello", $match)); - } - function testPatternLabels() { - $regex = new Doku_LexerParallelRegex(false); - $regex->addPattern("abc", "letter"); - $regex->addPattern("123", "number"); - $this->assertIdentical($regex->match("abcdef", $match), "letter"); - $this->assertEquals($match, "abc"); - $this->assertIdentical($regex->match("0123456789", $match), "number"); - $this->assertEquals($match, "123"); - } - function testMatchMultipleWithLookaheadNot() { - $regex = new Doku_LexerParallelRegex(true); - $regex->addPattern("abc"); - $regex->addPattern("ABC"); - $regex->addPattern("a(?!\n).{1}"); - $this->assertTrue($regex->match("abcdef", $match)); - $this->assertEquals($match, "abc"); - $this->assertTrue($regex->match("AAABCabcdef", $match)); - $this->assertEquals($match, "ABC"); - $this->assertTrue($regex->match("a\nab", $match)); - $this->assertEquals($match, "ab"); - $this->assertFalse($regex->match("Hello", $match)); - } - function testMatchSetOptionCaseless() { - $regex = new Doku_LexerParallelRegex(true); - $regex->addPattern("a(?i)b(?i)c"); - $this->assertTrue($regex->match("aBc", $match)); - $this->assertEquals($match, "aBc"); - } - function testMatchSetOptionUngreedy() { - $regex = new Doku_LexerParallelRegex(true); - $regex->addPattern("(?U)\w+"); - $this->assertTrue($regex->match("aaaaaa", $match)); - $this->assertEquals($match, "a"); - } - function testMatchLookaheadEqual() { - $regex = new Doku_LexerParallelRegex(true); - $regex->addPattern("\w(?=c)"); - $this->assertTrue($regex->match("xbyczd", $match)); - $this->assertEquals($match, "y"); - } - function testMatchLookaheadNot() { - $regex = new Doku_LexerParallelRegex(true); - $regex->addPattern("\w(?!b|c)"); - $this->assertTrue($regex->match("xbyczd", $match)); - $this->assertEquals($match, "b"); - } - function testMatchLookbehindEqual() { - $regex = new Doku_LexerParallelRegex(true); - $regex->addPattern("(?<=c)\w"); - $this->assertTrue($regex->match("xbyczd", $match)); - $this->assertEquals($match, "z"); - } - function testMatchLookbehindNot() { - $regex = new Doku_LexerParallelRegex(true); - $regex->addPattern("(?assertTrue($regex->match("xbyczd", $match)); - $this->assertEquals($match, "c"); - } -} - - -class TestOfLexerStateStack extends PHPUnit_Framework_TestCase { - function testStartState() { - $stack = new Doku_LexerStateStack("one"); - $this->assertEquals($stack->getCurrent(), "one"); - } - function testExhaustion() { - $stack = new Doku_LexerStateStack("one"); - $this->assertFalse($stack->leave()); - } - function testStateMoves() { - $stack = new Doku_LexerStateStack("one"); - $stack->enter("two"); - $this->assertEquals($stack->getCurrent(), "two"); - $stack->enter("three"); - $this->assertEquals($stack->getCurrent(), "three"); - $this->assertTrue($stack->leave()); - $this->assertEquals($stack->getCurrent(), "two"); - $stack->enter("third"); - $this->assertEquals($stack->getCurrent(), "third"); - $this->assertTrue($stack->leave()); - $this->assertTrue($stack->leave()); - $this->assertEquals($stack->getCurrent(), "one"); - } -} - -class TestParser { - function TestParser() { - } - function accept() { - } - function a() { - } - function b() { - } -} - -class TestOfLexer extends PHPUnit_Framework_TestCase { - function testNoPatterns() { - $handler = $this->getMock('TestParser'); - $handler->expects($this->never())->method('accept'); - $lexer = new Doku_Lexer($handler); - $this->assertFalse($lexer->parse("abcdef")); - } - function testEmptyPage() { - $handler = $this->getMock('TestParser'); - $handler->expects($this->never())->method('accept'); - $lexer = new Doku_Lexer($handler); - $lexer->addPattern("a+"); - $this->assertTrue($lexer->parse("")); - } - function testSinglePattern() { - $handler = $this->getMock('TestParser'); - $handler->expects($this->at(0))->method('accept') - ->with("aaa", DOKU_LEXER_MATCHED, 0)->will($this->returnValue(true)); - $handler->expects($this->at(1))->method('accept') - ->with("x", DOKU_LEXER_UNMATCHED, 3)->will($this->returnValue(true)); - $handler->expects($this->at(2))->method('accept') - ->with("a", DOKU_LEXER_MATCHED, 4)->will($this->returnValue(true)); - $handler->expects($this->at(3))->method('accept') - ->with("yyy", DOKU_LEXER_UNMATCHED, 5)->will($this->returnValue(true)); - $handler->expects($this->at(4))->method('accept') - ->with("a", DOKU_LEXER_MATCHED, 8)->will($this->returnValue(true)); - $handler->expects($this->at(5))->method('accept') - ->with("x", DOKU_LEXER_UNMATCHED, 9)->will($this->returnValue(true)); - $handler->expects($this->at(6))->method('accept') - ->with("aaa", DOKU_LEXER_MATCHED, 10)->will($this->returnValue(true)); - $handler->expects($this->at(7))->method('accept') - ->with("z", DOKU_LEXER_UNMATCHED, 13)->will($this->returnValue(true)); - - $lexer = new Doku_Lexer($handler); - $lexer->addPattern("a+"); - $this->assertTrue($lexer->parse("aaaxayyyaxaaaz")); - } - function testMultiplePattern() { - $handler = $this->getMock('TestParser', array('accept')); - $target = array("a", "b", "a", "bb", "x", "b", "a", "xxxxxx", "a", "x"); - $positions = array(0, 1, 2, 3, 5, 6, 7, 8, 14, 15); - for ($i = 0; $i < count($target); $i++) { - $handler->expects($this->at($i))->method('accept') - ->with($target[$i], $this->anything(), $positions[$i])->will($this->returnValue(true)); - } - $lexer = new Doku_Lexer($handler); - $lexer->addPattern("a+"); - $lexer->addPattern("b+"); - $this->assertTrue($lexer->parse("ababbxbaxxxxxxax")); - } -} - -class TestOfLexerModes extends PHPUnit_Framework_TestCase { - function testIsolatedPattern() { - $handler = $this->getMock('TestParser'); - $handler->expects($this->at(0))->method('a') - ->with("a", DOKU_LEXER_MATCHED,0)->will($this->returnValue(true)); - $handler->expects($this->at(1))->method('a') - ->with("b", DOKU_LEXER_UNMATCHED,1)->will($this->returnValue(true)); - $handler->expects($this->at(2))->method('a') - ->with("aa", DOKU_LEXER_MATCHED,2)->will($this->returnValue(true)); - $handler->expects($this->at(3))->method('a') - ->with("bxb", DOKU_LEXER_UNMATCHED,4)->will($this->returnValue(true)); - $handler->expects($this->at(4))->method('a') - ->with("aaa", DOKU_LEXER_MATCHED,7)->will($this->returnValue(true)); - $handler->expects($this->at(5))->method('a') - ->with("x", DOKU_LEXER_UNMATCHED,10)->will($this->returnValue(true)); - $handler->expects($this->at(6))->method('a') - ->with("aaaa", DOKU_LEXER_MATCHED,11)->will($this->returnValue(true)); - $handler->expects($this->at(7))->method('a') - ->with("x", DOKU_LEXER_UNMATCHED,15)->will($this->returnValue(true)); - $lexer = new Doku_Lexer($handler, "a"); - $lexer->addPattern("a+", "a"); - $lexer->addPattern("b+", "b"); - $this->assertTrue($lexer->parse("abaabxbaaaxaaaax")); - } - function testModeChange() { - $handler = $this->getMock('TestParser'); - $handler->expects($this->at(0))->method('a') - ->with("a", DOKU_LEXER_MATCHED,0)->will($this->returnValue(true)); - $handler->expects($this->at(1))->method('a') - ->with("b", DOKU_LEXER_UNMATCHED,1)->will($this->returnValue(true)); - $handler->expects($this->at(2))->method('a') - ->with("aa", DOKU_LEXER_MATCHED,2)->will($this->returnValue(true)); - $handler->expects($this->at(3))->method('a') - ->with("b", DOKU_LEXER_UNMATCHED,4)->will($this->returnValue(true)); - $handler->expects($this->at(4))->method('a') - ->with("aaa", DOKU_LEXER_MATCHED,5)->will($this->returnValue(true)); - - $handler->expects($this->at(0))->method('b') - ->with(":", DOKU_LEXER_ENTER,8)->will($this->returnValue(true)); - $handler->expects($this->at(1))->method('b') - ->with("a", DOKU_LEXER_UNMATCHED,9)->will($this->returnValue(true)); - $handler->expects($this->at(2))->method('b') - ->with("b", DOKU_LEXER_MATCHED, 10)->will($this->returnValue(true)); - $handler->expects($this->at(3))->method('b') - ->with("a", DOKU_LEXER_UNMATCHED,11)->will($this->returnValue(true)); - $handler->expects($this->at(4))->method('b') - ->with("bb", DOKU_LEXER_MATCHED,12)->will($this->returnValue(true)); - $handler->expects($this->at(5))->method('b') - ->with("a", DOKU_LEXER_UNMATCHED,14)->will($this->returnValue(true)); - $handler->expects($this->at(6))->method('b') - ->with("bbb", DOKU_LEXER_MATCHED,15)->will($this->returnValue(true)); - $handler->expects($this->at(7))->method('b') - ->with("a", DOKU_LEXER_UNMATCHED,18)->will($this->returnValue(true)); - - $lexer = new Doku_Lexer($handler, "a"); - $lexer->addPattern("a+", "a"); - $lexer->addEntryPattern(":", "a", "b"); - $lexer->addPattern("b+", "b"); - $this->assertTrue($lexer->parse("abaabaaa:ababbabbba")); - } - function testNesting() { - $handler = $this->getMock('TestParser'); - $handler->expectArgumentsAt(0, "a", array("aa", DOKU_LEXER_MATCHED,0)); - $handler->expectArgumentsAt(1, "a", array("b", DOKU_LEXER_UNMATCHED,2)); - $handler->expectArgumentsAt(2, "a", array("aa", DOKU_LEXER_MATCHED,3)); - $handler->expectArgumentsAt(3, "a", array("b", DOKU_LEXER_UNMATCHED,5)); - $handler->expectArgumentsAt(0, "b", array("(", DOKU_LEXER_ENTER,6)); - $handler->expectArgumentsAt(1, "b", array("bb", DOKU_LEXER_MATCHED,7)); - $handler->expectArgumentsAt(2, "b", array("a", DOKU_LEXER_UNMATCHED,9)); - $handler->expectArgumentsAt(3, "b", array("bb", DOKU_LEXER_MATCHED,10)); - $handler->expectArgumentsAt(4, "b", array(")", DOKU_LEXER_EXIT,12)); - $handler->expectArgumentsAt(4, "a", array("aa", DOKU_LEXER_MATCHED,13)); - $handler->expectArgumentsAt(5, "a", array("b", DOKU_LEXER_UNMATCHED,15)); - $lexer = new Doku_Lexer($handler, "a"); - $lexer->addPattern("a+", "a"); - $lexer->addEntryPattern("(", "a", "b"); - $lexer->addPattern("b+", "b"); - $lexer->addExitPattern(")", "b"); - $this->assertTrue($lexer->parse("aabaab(bbabb)aab")); - } - function testSingular() { - $handler = new MockTestParser($this); - $handler->setReturnValue("a", true); - $handler->setReturnValue("b", true); - $handler->expectArgumentsAt(0, "a", array("aa", DOKU_LEXER_MATCHED,0)); - $handler->expectArgumentsAt(1, "a", array("aa", DOKU_LEXER_MATCHED,3)); - $handler->expectArgumentsAt(2, "a", array("xx", DOKU_LEXER_UNMATCHED,5)); - $handler->expectArgumentsAt(3, "a", array("xx", DOKU_LEXER_UNMATCHED,10)); - $handler->expectArgumentsAt(0, "b", array("b", DOKU_LEXER_SPECIAL,2)); - $handler->expectArgumentsAt(1, "b", array("bbb", DOKU_LEXER_SPECIAL,7)); - $handler->expectCallCount("a", 4); - $handler->expectCallCount("b", 2); - $lexer = new Doku_Lexer($handler, "a"); - $lexer->addPattern("a+", "a"); - $lexer->addSpecialPattern("b+", "a", "b"); - $this->assertTrue($lexer->parse("aabaaxxbbbxx")); - $handler->tally(); - } - function testUnwindTooFar() { - $handler = new MockTestParser($this); - $handler->setReturnValue("a", true); - $handler->expectArgumentsAt(0, "a", array("aa", DOKU_LEXER_MATCHED,0)); - $handler->expectArgumentsAt(1, "a", array(")", DOKU_LEXER_EXIT,2)); - $handler->expectCallCount("a", 2); - $lexer = new Doku_Lexer($handler, "a"); - $lexer->addPattern("a+", "a"); - $lexer->addExitPattern(")", "a"); - $this->assertFalse($lexer->parse("aa)aa")); - $handler->tally(); - } -} - -class TestOfLexerHandlers extends PHPUnit_Framework_TestCase { - function testModeMapping() { - $handler = new MockTestParser($this); - $handler->setReturnValue("a", true); - $handler->expectArgumentsAt(0, "a", array("aa", DOKU_LEXER_MATCHED,0)); - $handler->expectArgumentsAt(1, "a", array("(", DOKU_LEXER_ENTER,2)); - $handler->expectArgumentsAt(2, "a", array("bb", DOKU_LEXER_MATCHED,3)); - $handler->expectArgumentsAt(3, "a", array("a", DOKU_LEXER_UNMATCHED,5)); - $handler->expectArgumentsAt(4, "a", array("bb", DOKU_LEXER_MATCHED,6)); - $handler->expectArgumentsAt(5, "a", array(")", DOKU_LEXER_EXIT,8)); - $handler->expectArgumentsAt(6, "a", array("b", DOKU_LEXER_UNMATCHED,9)); - $handler->expectCallCount("a", 7); - $lexer = new Doku_Lexer($handler, "mode_a"); - $lexer->addPattern("a+", "mode_a"); - $lexer->addEntryPattern("(", "mode_a", "mode_b"); - $lexer->addPattern("b+", "mode_b"); - $lexer->addExitPattern(")", "mode_b"); - $lexer->mapHandler("mode_a", "a"); - $lexer->mapHandler("mode_b", "a"); - $this->assertTrue($lexer->parse("aa(bbabb)b")); - $handler->tally(); - } -} - -class TestParserByteIndex { - - function TestParserByteIndex() {} - - function ignore() {} - - function caught() {} -} - -Mock::generate('TestParserByteIndex'); - -class TestOfLexerByteIndices extends PHPUnit_Framework_TestCase { - - function testIndex() { - $doc = "aaabcdeee"; - - $handler = new MockTestParserByteIndex($this); - $handler->setReturnValue("ignore", true); - $handler->setReturnValue("caught", true); - - $handler->expectArgumentsAt( - 0, - "caught", - array("", DOKU_LEXER_ENTER, strpos($doc,'')) - ); - $handler->expectArgumentsAt( - 1, - "caught", - array("b", DOKU_LEXER_SPECIAL, strpos($doc,'b')) - ); - $handler->expectArgumentsAt( - 2, - "caught", - array("c", DOKU_LEXER_MATCHED, strpos($doc,'c')) - ); - $handler->expectArgumentsAt( - 3, - "caught", - array("d", DOKU_LEXER_UNMATCHED, strpos($doc,'d')) - ); - $handler->expectArgumentsAt( - 4, - "caught", - array("", DOKU_LEXER_EXIT, strpos($doc,'')) - ); - $handler->expectCallCount("caught", 5); - - $lexer = new Doku_Lexer($handler, "ignore"); - $lexer->addEntryPattern("", "ignore", "caught"); - $lexer->addExitPattern("", "caught"); - $lexer->addSpecialPattern('b','caught','special'); - $lexer->mapHandler('special','caught'); - $lexer->addPattern('c','caught'); - - $this->assertTrue($lexer->parse($doc)); - $handler->tally(); - } - - function testIndexLookaheadEqual() { - $doc = "aaabcdeee"; - - $handler = new MockTestParserByteIndex($this); - $handler->setReturnValue("ignore", true); - $handler->setReturnValue("caught", true); - - $handler->expectArgumentsAt( - 0, - "caught", - array("", DOKU_LEXER_ENTER, strpos($doc,'')) - ); - $handler->expectArgumentsAt( - 1, - "caught", - array("b", DOKU_LEXER_SPECIAL, strpos($doc,'b')) - ); - $handler->expectArgumentsAt( - 2, - "caught", - array("c", DOKU_LEXER_MATCHED, strpos($doc,'c')) - ); - $handler->expectArgumentsAt( - 3, - "caught", - array("d", DOKU_LEXER_UNMATCHED, strpos($doc,'d')) - ); - $handler->expectArgumentsAt( - 4, - "caught", - array("", DOKU_LEXER_EXIT, strpos($doc,'')) - ); - $handler->expectCallCount("caught", 5); - - $lexer = new Doku_Lexer($handler, "ignore"); - $lexer->addEntryPattern('(?=.*)', "ignore", "caught"); - $lexer->addExitPattern("", "caught"); - $lexer->addSpecialPattern('b','caught','special'); - $lexer->mapHandler('special','caught'); - $lexer->addPattern('c','caught'); - - $this->assertTrue($lexer->parse($doc)); - $handler->tally(); - } - - function testIndexLookaheadNotEqual() { - $doc = "aaabcdeee"; - - $handler = new MockTestParserByteIndex($this); - $handler->setReturnValue("ignore", true); - $handler->setReturnValue("caught", true); - - $handler->expectArgumentsAt( - 0, - "caught", - array("", DOKU_LEXER_ENTER, strpos($doc,'')) - ); - $handler->expectArgumentsAt( - 1, - "caught", - array("b", DOKU_LEXER_SPECIAL, strpos($doc,'b')) - ); - $handler->expectArgumentsAt( - 2, - "caught", - array("c", DOKU_LEXER_MATCHED, strpos($doc,'c')) - ); - $handler->expectArgumentsAt( - 3, - "caught", - array("d", DOKU_LEXER_UNMATCHED, strpos($doc,'d')) - ); - $handler->expectArgumentsAt( - 4, - "caught", - array("", DOKU_LEXER_EXIT, strpos($doc,'')) - ); - $handler->expectCallCount("caught", 5); - - $lexer = new Doku_Lexer($handler, "ignore"); - $lexer->addEntryPattern('(?!foo)', "ignore", "caught"); - $lexer->addExitPattern("", "caught"); - $lexer->addSpecialPattern('b','caught','special'); - $lexer->mapHandler('special','caught'); - $lexer->addPattern('c','caught'); - - $this->assertTrue($lexer->parse($doc)); - $handler->tally(); - } - - function testIndexLookbehindEqual() { - $doc = "aaabcdeee"; - - $handler = new MockTestParserByteIndex($this); - $handler->setReturnValue("ignore", true); - $handler->setReturnValue("caught", true); - - $handler->expectArgumentsAt( - 0, - "caught", - array("", DOKU_LEXER_ENTER, strpos($doc,'')) - ); - $handler->expectArgumentsAt( - 1, - "caught", - array("b", DOKU_LEXER_SPECIAL, strpos($doc,'b')) - ); - $handler->expectArgumentsAt( - 2, - "caught", - array("c", DOKU_LEXER_MATCHED, strpos($doc,'c')) - ); - $handler->expectArgumentsAt( - 3, - "caught", - array("d", DOKU_LEXER_UNMATCHED, strpos($doc,'d')) - ); - $handler->expectArgumentsAt( - 4, - "caught", - array("", DOKU_LEXER_EXIT, strpos($doc,'')) - ); - $handler->expectCallCount("caught", 5); - - $lexer = new Doku_Lexer($handler, "ignore"); - $lexer->addEntryPattern('', "ignore", "caught"); - $lexer->addExitPattern("(?<=d)", "caught"); - $lexer->addSpecialPattern('b','caught','special'); - $lexer->mapHandler('special','caught'); - $lexer->addPattern('c','caught'); - - $this->assertTrue($lexer->parse($doc)); - $handler->tally(); - } - - function testIndexLookbehindNotEqual() { - $doc = "aaabcdeee"; - - $handler = new MockTestParserByteIndex($this); - $handler->setReturnValue("ignore", true); - $handler->setReturnValue("caught", true); - - $handler->expectArgumentsAt( - 0, - "caught", - array("", DOKU_LEXER_ENTER, strpos($doc,'')) - ); - $handler->expectArgumentsAt( - 1, - "caught", - array("b", DOKU_LEXER_SPECIAL, strpos($doc,'b')) - ); - $handler->expectArgumentsAt( - 2, - "caught", - array("c", DOKU_LEXER_MATCHED, strpos($doc,'c')) - ); - $handler->expectArgumentsAt( - 3, - "caught", - array("d", DOKU_LEXER_UNMATCHED, strpos($doc,'d')) - ); - $handler->expectArgumentsAt( - 4, - "caught", - array("", DOKU_LEXER_EXIT, strpos($doc,'')) - ); - $handler->expectCallCount("caught", 5); - - $lexer = new Doku_Lexer($handler, "ignore"); - $lexer->addEntryPattern('', "ignore", "caught"); - $lexer->addExitPattern("(?", "caught"); - $lexer->addSpecialPattern('b','caught','special'); - $lexer->mapHandler('special','caught'); - $lexer->addPattern('c','caught'); - - $this->assertTrue($lexer->parse($doc)); - $handler->tally(); - } - - /** - * This test is primarily to ensure the correct match is chosen - * when there are non-captured elements in the pattern. - */ - function testIndexSelectCorrectMatch() { - $doc = "ALL FOOLS ARE FOO"; - $pattern = '\bFOO\b'; - - $handler = new MockTestParserByteIndex($this); - $handler->setReturnValue("ignore", true); - $handler->setReturnValue("caught", true); - - $matches = array(); - preg_match('/'.$pattern.'/',$doc,$matches,PREG_OFFSET_CAPTURE); - - $handler->expectArgumentsAt( - 0, - "caught", - array("FOO", DOKU_LEXER_SPECIAL, $matches[0][1]) - ); - $handler->expectCallCount("caught", 1); - - $lexer = new Doku_Lexer($handler, "ignore"); - $lexer->addSpecialPattern($pattern,'ignore','caught'); - - $this->assertTrue($lexer->parse($doc)); - $handler->tally(); - } - -} - -?> -- cgit v1.2.3