2013-12-01 21:14:16 -08:00
|
|
|
<?php
|
|
|
|
|
include_once 'hammer.php';
|
|
|
|
|
|
|
|
|
|
class ChoiceTest extends PHPUnit_Framework_TestCase
|
|
|
|
|
{
|
|
|
|
|
protected $parser;
|
|
|
|
|
|
|
|
|
|
protected function setUp()
|
|
|
|
|
{
|
2013-12-18 00:32:56 +01:00
|
|
|
$this->parser = hammer_choice(hammer_ch("a"), hammer_ch("b"));
|
2013-12-01 21:14:16 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function testSuccess()
|
|
|
|
|
{
|
2013-12-18 00:32:56 +01:00
|
|
|
$result1 = hammer_parse($this->parser, "a");
|
|
|
|
|
$result2 = hammer_parse($this->parser, "b");
|
2013-12-01 21:14:16 -08:00
|
|
|
$this->assertEquals("a", $result1);
|
|
|
|
|
$this->assertEquals("b", $result2);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function testFailure()
|
|
|
|
|
{
|
2013-12-18 00:32:56 +01:00
|
|
|
$result = hammer_parse($this->parser, "c");
|
2013-12-01 21:14:16 -08:00
|
|
|
$this->assertEquals(NULL, $result);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
?>
|