From 96470902e2555016ee813612e6524c8adf2df306 Mon Sep 17 00:00:00 2001 From: "Meredith L. Patterson" <mlp@thesmartpolitenerd.com> Date: Sun, 1 Dec 2013 22:13:24 -0800 Subject: [PATCH] all tests written. --- src/bindings/php/Tests/RightrecTest.php | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 src/bindings/php/Tests/RightrecTest.php diff --git a/src/bindings/php/Tests/RightrecTest.php b/src/bindings/php/Tests/RightrecTest.php new file mode 100644 index 00000000..9580fdec --- /dev/null +++ b/src/bindings/php/Tests/RightrecTest.php @@ -0,0 +1,24 @@ +<?php +include_once 'hammer.php'; + +class RightrecTest extends PHPUnit_Framework_TestCase +{ + protected $parser; + + protected function setUp() + { + $this->parser = h_indirect(); + h_bind_indirect($this->parser, choice(sequence(ch("a"), $this->parser), h_epsilon_p())); + } + + public function testSuccess() + { + $result1 = h_parse($this->parser, "a"); + $result2 = h_parse($this->parser, "aa"); + $result3 = h_parse($this->parser, "aaa"); + $this->assertEquals(array("a"), $result1); + $this->assertEquals(array("a", array("a")), $result2); + $this->assertEquals(array("a", array("a", array("a"))), $result3); + } +} +?> \ No newline at end of file -- GitLab