From 1ce63c26ec1aeefe030e28dd3b01d78168b0a965 Mon Sep 17 00:00:00 2001
From: "Meredith L. Patterson" <mlp@thesmartpolitenerd.com>
Date: Sun, 1 Dec 2013 21:11:15 -0800
Subject: [PATCH] sequence is definitely broken, results aren't landing in
 output array

---
 src/bindings/php/Tests/EndTest.php      |  2 +-
 src/bindings/php/Tests/SequenceTest.php | 39 +++++++++++++++++++++++++
 2 files changed, 40 insertions(+), 1 deletion(-)
 create mode 100644 src/bindings/php/Tests/SequenceTest.php

diff --git a/src/bindings/php/Tests/EndTest.php b/src/bindings/php/Tests/EndTest.php
index 53955ed4..6a871fa7 100644
--- a/src/bindings/php/Tests/EndTest.php
+++ b/src/bindings/php/Tests/EndTest.php
@@ -20,7 +20,7 @@ class EndPTest extends PHPUnit_Framework_TestCase
     {
         $result = h_parse($this->parser, "aa");
         var_dump($result);
-        $this->assertEquals(array(), $result);
+        $this->assertEquals(NULL, $result);
     }
 }
 ?>
\ No newline at end of file
diff --git a/src/bindings/php/Tests/SequenceTest.php b/src/bindings/php/Tests/SequenceTest.php
new file mode 100644
index 00000000..67ae1f05
--- /dev/null
+++ b/src/bindings/php/Tests/SequenceTest.php
@@ -0,0 +1,39 @@
+<?php
+include_once 'hammer.php';
+
+class SequenceTest extends PHPUnit_Framework_TestCase
+{
+    protected $parser1;
+    protected $parser2;
+
+    protected function setUp()
+    {
+        $this->parser1 = sequence(ch("a"), ch("b"));
+        $this->parser2 = sequence(ch("a"), h_whitespace(ch("b")));
+    }
+
+    public function testSuccess1()
+    {
+        $result = h_parse($this->parser1, "ab");
+        $this->assertEquals(array("a", "b"), $result);
+    }
+    
+    public function testFailure1()
+    {
+        $result1 = h_parse($this->parser1, "a");
+        $result2 = h_parse($this->parser2, "b");
+        $this->assertEquals(NULL, $result1);
+        $this->assertEquals(NULL, $result2);
+    }
+
+    public function testSuccess2()
+    {
+        $result1 = h_parse($this->parser2, "ab");
+        $result2 = h_parse($this->parser2, "a b");
+        $result3 = h_parse($this->parser2, "a  b");
+        $this->assertEquals(array("a", "b"), $result1);
+        $this->assertEquals(array("a", "b"), $result2);
+        $this->assertEquals(array("a", "b"), $result3);
+    }
+}
+?>
\ No newline at end of file
-- 
GitLab