From 5c5a10b5c1d56e42153bc1dc7b88571f7d3d510b Mon Sep 17 00:00:00 2001
From: "Meredith L. Patterson" <mlp@thesmartpolitenerd.com>
Date: Sun, 1 Dec 2013 21:51:57 -0800
Subject: [PATCH] sepby also plagued by sequence/choice return issues

---
 src/bindings/php/Tests/SepBy1Test.php | 31 +++++++++++++++++++++++++++
 src/bindings/php/Tests/SepByTest.php  | 27 +++++++++++++++++++++++
 2 files changed, 58 insertions(+)
 create mode 100644 src/bindings/php/Tests/SepBy1Test.php
 create mode 100644 src/bindings/php/Tests/SepByTest.php

diff --git a/src/bindings/php/Tests/SepBy1Test.php b/src/bindings/php/Tests/SepBy1Test.php
new file mode 100644
index 00000000..a5a36cc3
--- /dev/null
+++ b/src/bindings/php/Tests/SepBy1Test.php
@@ -0,0 +1,31 @@
+<?php
+include_once 'hammer.php';
+
+class SepBy1Test extends PHPUnit_Framework_TestCase
+{
+    protected $parser;
+
+    protected function setUp()
+    {
+        $this->parser = h_sepBy1(choice(ch("1"), ch("2"), ch("3")), ch(","));
+    }
+
+    public function testSuccess()
+    {
+        $result1 = h_parse($this->parser, "1,2,3");
+        $result2 = h_parse($this->parser, "1,3,2");
+        $result3 = h_parse($this->parser, "1,3");
+        $result4 = h_parse($this->parser, "3");
+        $this->assertEquals(array("1", "2", "3"), $result1);
+        $this->assertEquals(array("1", "3", "2"), $result2);
+        $this->assertEquals(array("1", "3"), $result3);
+        $this->assertEquals(array("3"), $result4);
+    }
+
+    public function testFailure()
+    {
+        $result = h_parse($this->parser, "");
+        $this->assertEquals(NULL, $result);
+    }
+}
+?>
\ No newline at end of file
diff --git a/src/bindings/php/Tests/SepByTest.php b/src/bindings/php/Tests/SepByTest.php
new file mode 100644
index 00000000..fdf4ed49
--- /dev/null
+++ b/src/bindings/php/Tests/SepByTest.php
@@ -0,0 +1,27 @@
+<?php
+include_once 'hammer.php';
+
+class SepByTest extends PHPUnit_Framework_TestCase
+{
+    protected $parser;
+
+    protected function setUp()
+    {
+        $this->parser = h_sepBy(choice(ch("1"), ch("2"), ch("3")), ch(","));
+    }
+
+    public function testSuccess()
+    {
+        $result1 = h_parse($this->parser, "1,2,3");
+        $result2 = h_parse($this->parser, "1,3,2");
+        $result3 = h_parse($this->parser, "1,3");
+        $result4 = h_parse($this->parser, "3");
+        $result5 = h_parse($this->parser, "");
+        $this->assertEquals(array("1", "2", "3"), $result1);
+        $this->assertEquals(array("1", "3", "2"), $result2);
+        $this->assertEquals(array("1", "3"), $result3);
+        $this->assertEquals(array("3"), $result4);
+        $this->assertEquals(array(), $result5);
+    }
+}
+?>
\ No newline at end of file
-- 
GitLab