From e9de06636d351dd9c87e1fc36fcfd8daa1382dc1 Mon Sep 17 00:00:00 2001 From: "Meredith L. Patterson" <mlp@thesmartpolitenerd.com> Date: Sun, 1 Dec 2013 21:29:11 -0800 Subject: [PATCH] h_many is failing because of the problem with choice not returning results correctly --- src/bindings/php/Tests/ManyTest.php | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 src/bindings/php/Tests/ManyTest.php diff --git a/src/bindings/php/Tests/ManyTest.php b/src/bindings/php/Tests/ManyTest.php new file mode 100644 index 00000000..ef1d0962 --- /dev/null +++ b/src/bindings/php/Tests/ManyTest.php @@ -0,0 +1,25 @@ +<?php +include_once 'hammer.php'; + +class ManyTest extends PHPUnit_Framework_TestCase +{ + protected $parser; + + protected function setUp() + { + $this->parser = h_many(choice(ch("a"), ch("b"))); + } + + public function testSuccess() + { + $result1 = h_parse($this->parser, ""); + $result2 = h_parse($this->parser, "a"); + $result3 = h_parse($this->parser, "b"); + $result4 = h_parse($this->parser, "aabbaba"); + $this->assertEquals(array(), $result); + $this->assertEquals(array("a"), $result); + $this->assertEquals(array("b"), $result); + $this->assertEquals(array("a", "a", "b", "b", "a", "b", "a"), $result); + } +} +?> \ No newline at end of file -- GitLab