Skip to content

Commit

Permalink
refine tests and comments
Browse files Browse the repository at this point in the history
  • Loading branch information
Zordius Chen committed Jan 27, 2016
1 parent 8ff4bec commit 061c645
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/Parser.php
Original file line number Diff line number Diff line change
Expand Up @@ -224,12 +224,12 @@ public static function parse(&$token, &$context) {
}

/**
* Get block params and fix the variable list
* Get partial name from "foo" or [foo] or 'foo'
*
* @param array<boolean|integer|array> $vars parsed token
* @param integer $pos position of partial name
*
* @return array<string>|null Return list of block params or null
* @return array<string>|null Return one element partial name array
*
*/
public static function getPartialName(&$vars, $pos = 0) {
Expand All @@ -246,6 +246,8 @@ public static function getPartialName(&$vars, $pos = 0) {
* @param array<string,array|string|integer> $context current compile context
*
* @return array<boolean|integer|array> Return parsed result
*
* @expect array(\LightnCandy\Parser::SUBEXP, array(array('a'), array('b')), '(a b)') when input '(a b)', array('usedFeature' => array('subexp' => 0), 'flags' => array('advar' => 0, 'namev' => 0, 'this' => 0, 'exhlp' => 1, 'strpar' => 0))
*/
public static function subexpression($expression, &$context) {
$context['usedFeature']['subexp']++;
Expand Down
9 changes: 9 additions & 0 deletions tests/ParserTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,15 @@ public function testOn_parse() {
array(0,0,0,0,0,0,'>','\\\'foo\\\''), array('flags' => array('strpar' => 0, 'advar' => 1, 'this' => 1, 'namev' => 1, 'noesc' => 0, 'exhlp' => 0, 'lambda' => 0), 'usedFeature' => array('subexp' => 0), 'ops' => array('seperator' => 0), 'rawblock' => false)
))));
}
/**
* @covers LightnCandy\Parser::subexpression
*/
public function testOn_subexpression() {
$method = new \ReflectionMethod('LightnCandy\Parser', 'subexpression');
$this->assertEquals(array(\LightnCandy\Parser::SUBEXP, array(array('a'), array('b')), '(a b)'), $method->invokeArgs(null, array_by_ref(array(
'(a b)', array('usedFeature' => array('subexp' => 0), 'flags' => array('advar' => 0, 'namev' => 0, 'this' => 0, 'exhlp' => 1, 'strpar' => 0))
))));
}
/**
* @covers LightnCandy\Parser::isSubExp
*/
Expand Down

0 comments on commit 061c645

Please sign in to comment.