nothing_p works; EndTest's failure case is producing an empty array (successful but empty sequence), success case is *also* producing an empty array

This commit is contained in:
Meredith L. Patterson 2013-12-01 21:04:54 -08:00
parent 9f55409246
commit fc71e12bea
2 changed files with 22 additions and 3 deletions

View file

@ -12,15 +12,15 @@ class EndPTest extends PHPUnit_Framework_TestCase
public function testSuccess()
{
$result = h_parse($this->parser, ["a"]);
$result = h_parse($this->parser, "a");
var_dump($result);
$this->assertEquals("a", $result);
$this->assertEquals(array("a"), $result);
}
public function testFailure()
{
$result = h_parse($this->parser, "aa");
var_dump($result);
$this->assertEquals(NULL, $result);
$this->assertEquals(array(), $result);
}
}
?>

View file

@ -0,0 +1,19 @@
<?php
include_once 'hammer.php';
class NothingPTest extends PHPUnit_Framework_TestCase
{
protected $parser;
protected function setUp()
{
$this->parser = h_nothing_p();
}
public function testFailure()
{
$result = h_parse($this->parser, "a");
$this->assertEquals(NULL, $result);
}
}
?>