aboutsummaryrefslogtreecommitdiffstats
path: root/Iterator
diff options
context:
space:
mode:
authorIvan Enderlin <ivan.enderlin@hoa-project.net>2013-06-24 12:51:52 +0200
committerIvan Enderlin <ivan.enderlin@hoa-project.net>2013-06-24 12:51:52 +0200
commit306cf4d106f8387914a4fcffc8a372ab5987bc2e (patch)
tree31cb80457e1fc37eac868689e9a1ec7bc0702a82 /Iterator
parent847ec6de83bd381defbac94f2c03b456cad08ca1 (diff)
downloadPraspel-306cf4d106f8387914a4fcffc8a372ab5987bc2e.zip
Praspel-306cf4d106f8387914a4fcffc8a372ab5987bc2e.tar.gz
Praspel-306cf4d106f8387914a4fcffc8a372ab5987bc2e.tar.bz2
Add coverage of the @default clause.
Diffstat (limited to 'Iterator')
-rw-r--r--Iterator/Coverage/Structural.php37
1 files changed, 32 insertions, 5 deletions
diff --git a/Iterator/Coverage/Structural.php b/Iterator/Coverage/Structural.php
index 02c9156..ccfb1a9 100644
--- a/Iterator/Coverage/Structural.php
+++ b/Iterator/Coverage/Structural.php
@@ -111,7 +111,7 @@ class Structural implements \Hoa\Iterator\Recursive {
*
* @var \Hoa\Praspel\Iterator\Coverage\Structural int
*/
- protected $_key = -1;
+ protected $_key = 0;
/**
* Current (with two indexes: pre and post, with SplStack
@@ -195,6 +195,7 @@ class Structural implements \Hoa\Iterator\Recursive {
$this->_up = false;
$this->_post = 'throwable';
+ ++$this->_key;
$this->_rewindCurrent();
return $this->current();
@@ -213,6 +214,24 @@ class Structural implements \Hoa\Iterator\Recursive {
return $this->next();
}
+ elseif($collection instanceof \Hoa\Praspel\Model\DefaultBehavior) {
+
+ if(false === $this->_up) {
+
+ $this->pushCurrent($collection);
+ $this->_up = true;
+ ++$this->_key;
+
+ return $this->current();
+ }
+
+ $this->_current['pre']->pop();
+ $this->_current['post']->pop();
+
+ $this->_stack->pop();
+
+ return $this->next();
+ }
$handle = current($collection);
@@ -224,19 +243,27 @@ class Structural implements \Hoa\Iterator\Recursive {
$this->_current['post']->pop();
next($collection);
- $handle = current($collection);
+ $nextHandle = current($collection);
- if(false === $handle) {
+ if(false === $nextHandle) {
$this->_stack->pop();
+
+ if(true === $handle->getParent()->clauseExists('default')) {
+
+ $this->_up = false;
+ $this->_stack->push($handle->getParent()->getClause('default'));
+
+ return $this->next();
+ }
+
$this->_up = true;
return $this->next();
}
$this->_up = false;
- $this->pushCurrent($handle);
-
+ $this->pushCurrent($nextHandle);
++$this->_key;
return $this->current();