diff --git a/src/bindings/php/Tests/SepBy1Test.php b/src/bindings/php/Tests/SepBy1Test.php new file mode 100644 index 0000000..a5a36cc --- /dev/null +++ b/src/bindings/php/Tests/SepBy1Test.php @@ -0,0 +1,31 @@ +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 0000000..fdf4ed4 --- /dev/null +++ b/src/bindings/php/Tests/SepByTest.php @@ -0,0 +1,27 @@ +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