choice isn't putting its results in the right place either

This commit is contained in:
Meredith L. Patterson 2013-12-01 21:14:16 -08:00
parent 1ce63c26ec
commit 80d4460e6e

View file

@ -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);
}
}
?>