hammer/src/bindings/php/Tests/ButNotTest.php
Meredith L. Patterson 378710844b h_butnot is fine
2013-12-22 18:09:25 +01:00

35 lines
No EOL
825 B
PHP

<?php
include_once 'hammer.php';
class ButNotTest extends PHPUnit_Framework_TestCase
{
protected $parser1;
protected $parser2;
protected function setUp()
{
$this->parser1 = h_butnot(ch("a"), h_token("ab"));
$this->parser2 = h_butnot(h_ch_range('0', '9'), ch('6'));
}
public function testSuccess1()
{
$result1 = h_parse($this->parser1, "a");
$result2 = h_parse($this->parser1, "aa");
$this->assertEquals("a", $result1);
$this->assertEquals("a", $result1);
}
public function testFailure1()
{
$result = h_parse($this->parser1, "ab");
$this->assertEquals(NULL, $result);
}
public function testFailure2()
{
$result = h_parse($this->parser2, "6");
$this->assertEquals(NULL, $result);
}
}
?>