From 80d4460e6e19723f60cd4aaec3c040a650632fde Mon Sep 17 00:00:00 2001 From: "Meredith L. Patterson" <mlp@thesmartpolitenerd.com> Date: Sun, 1 Dec 2013 21:14:16 -0800 Subject: [PATCH] choice isn't putting its results in the right place either --- src/bindings/php/Tests/ChoiceTest.php | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 src/bindings/php/Tests/ChoiceTest.php diff --git a/src/bindings/php/Tests/ChoiceTest.php b/src/bindings/php/Tests/ChoiceTest.php new file mode 100644 index 00000000..42bb0a90 --- /dev/null +++ b/src/bindings/php/Tests/ChoiceTest.php @@ -0,0 +1,27 @@ +<?php +include_once 'hammer.php'; + +class ChoiceTest extends PHPUnit_Framework_TestCase +{ + protected $parser; + + protected function setUp() + { + $this->parser = choice(ch("a"), ch("b")); + } + + public function testSuccess() + { + $result1 = h_parse($this->parser, "a"); + $result2 = h_parse($this->parser, "b"); + $this->assertEquals("a", $result1); + $this->assertEquals("b", $result2); + } + + public function testFailure() + { + $result = h_parse($this->parser, "c"); + $this->assertEquals(NULL, $result); + } +} +?> \ No newline at end of file -- GitLab