diff --git a/src/bindings/php/Tests/ChoiceTest.php b/src/bindings/php/Tests/ChoiceTest.php new file mode 100644 index 0000000000000000000000000000000000000000..42bb0a90a94e57ca850195b52091c5cf6e91592f --- /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