2013-12-01 22:09:45 -08:00
|
|
|
<?php
|
|
|
|
|
include_once 'hammer.php';
|
|
|
|
|
|
|
|
|
|
class LeftrecTest extends PHPUnit_Framework_TestCase
|
|
|
|
|
{
|
|
|
|
|
protected $parser;
|
|
|
|
|
|
|
|
|
|
protected function setUp()
|
|
|
|
|
{
|
|
|
|
|
$this->parser = h_indirect();
|
|
|
|
|
h_bind_indirect($this->parser, choice(sequence($this->parser, ch("a")), ch("a")));
|
|
|
|
|
}
|
|
|
|
|
|
2013-12-10 00:53:35 +01:00
|
|
|
public function testSuccess1()
|
2013-12-01 22:09:45 -08:00
|
|
|
{
|
2013-12-10 00:53:35 +01:00
|
|
|
$result = h_parse($this->parser, "a");
|
|
|
|
|
$this->assertEquals("a", $result);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function testSuccess2()
|
|
|
|
|
{
|
|
|
|
|
$result = h_parse($this->parser, "aa");
|
|
|
|
|
var_dump($result);
|
2013-12-01 22:09:45 -08:00
|
|
|
$this->assertEquals(array("a", "a"), $result);
|
2013-12-10 00:53:35 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function testSuccess3()
|
|
|
|
|
{
|
|
|
|
|
$result = h_parse($this->parser, "aaa");
|
|
|
|
|
var_dump($result);
|
2013-12-01 22:09:45 -08:00
|
|
|
$this->assertEquals(array(array("a", "a"), "a"), $result);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
?>
|