fix ch_range; confirm action works with sequences too

This commit is contained in:
Meredith L. Patterson 2013-12-16 13:18:54 +01:00
parent 6c9410d8de
commit 2730d9ffd7
3 changed files with 13 additions and 5 deletions

View file

@ -4,7 +4,10 @@ include_once 'hammer.php';
function actTest($token)
{
if (is_array($token) === true) {
return strtoupper(join('', $token));
foreach($token as $chr) {
$ret[] = strtoupper($chr);
}
return $ret;
} else {
return strtoupper($token);
}
@ -23,9 +26,9 @@ class ActionTest extends PHPUnit_Framework_TestCase
$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);
$this->assertEquals(["A", "B"], $result1);
$this->assertEquals(["A", "B"], $result2);
$this->assertEquals(["A", "B"], $result3);
}
public function testFailure()
{

View file

@ -8,7 +8,7 @@ class ChRangeTest extends PHPUnit_Framework_TestCase
protected function setUp()
{
$this->parser = h_ch_range("a", "c");
$this->parser = ch_range("a", "c");
}
public function testSuccess()
{

View file

@ -175,6 +175,11 @@ function sequence()
return h_sequence__a($arg_list);
}
function ch_range($low, $high)
{
return action(h_ch_range($low, $high), \"chr\");
}
function in($charset)
{
return action(h_in($charset), \"chr\");