h_action test is written, but something is wrong with h_choice.
This commit is contained in:
parent
72edbfa167
commit
ce5a621ee3
1 changed files with 32 additions and 0 deletions
32
src/bindings/php/Tests/ActionTest.php
Normal file
32
src/bindings/php/Tests/ActionTest.php
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
<?php
|
||||
include_once 'hammer.php';
|
||||
|
||||
class ActionTest extends PHPUnit_Framework_TestCase
|
||||
{
|
||||
protected $parser;
|
||||
|
||||
protected function actTest(string $token)
|
||||
{
|
||||
return strtoupper($token);
|
||||
}
|
||||
protected function setUp()
|
||||
{
|
||||
$this->parser = h_action(h_sequence(h_choice(h_ch("a"), h_ch("A")), h_choice(h_ch("b"), h_ch("B"))), "actTest");
|
||||
}
|
||||
public function testSuccess()
|
||||
{
|
||||
$result1 = h_parse($this->parser, "ab");
|
||||
$result2 = h_parse($this->parser, "AB");
|
||||
$result3 = h_parse($this->parser, "aB");
|
||||
$this->assertEquals("AB", $result1);
|
||||
$this->assertEquals("AB", $result2);
|
||||
$this->assertEquals("AB", $result3);
|
||||
}
|
||||
public function testFailure()
|
||||
{
|
||||
$result = h_parse($this->parser, "XX");
|
||||
$this->assertEquals(NULL, $result);
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
Loading…
Add table
Add a link
Reference in a new issue