2013-11-30 16:58:27 -08:00
|
|
|
<?php
|
|
|
|
|
include_once 'hammer.php';
|
|
|
|
|
|
|
|
|
|
class RightTest extends PHPUnit_Framework_TestCase
|
|
|
|
|
{
|
|
|
|
|
protected $parser;
|
|
|
|
|
|
|
|
|
|
protected function setUp()
|
|
|
|
|
{
|
2013-12-01 16:07:25 -08:00
|
|
|
$this->parser = h_right(ch(" "), ch("a"));
|
2013-11-30 16:58:27 -08:00
|
|
|
}
|
|
|
|
|
public function testSuccess()
|
|
|
|
|
{
|
|
|
|
|
$result = h_parse($this->parser, " a");
|
2013-12-01 16:07:25 -08:00
|
|
|
$this->assertEquals("a", $result);
|
2013-11-30 16:58:27 -08:00
|
|
|
}
|
|
|
|
|
public function testFailure()
|
|
|
|
|
{
|
|
|
|
|
$result1 = h_parse($this->parser, "a");
|
|
|
|
|
$result2 = h_parse($this->parser, " ");
|
|
|
|
|
$result3 = h_parse($this->parser, "ba");
|
|
|
|
|
$this->assertEquals(NULL, $result1);
|
|
|
|
|
$this->assertEquals(NULL, $result2);
|
|
|
|
|
$this->assertEquals(NULL, $result3);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
?>
|