aboutsummaryrefslogtreecommitdiffstats
path: root/Iterator
diff options
context:
space:
mode:
authorIvan Enderlin <ivan.enderlin@hoa-project.net>2013-05-01 12:33:04 +0200
committerIvan Enderlin <ivan.enderlin@hoa-project.net>2013-05-01 12:33:04 +0200
commit63898995a0ef49ec3d38d8370ae252520c28f1ab (patch)
tree21ef939a87b58e87691d891dc9aad8b1ecb606ee /Iterator
parent9b38d6291ab08aadf4c565e6f9b218f689920688 (diff)
downloadPraspel-63898995a0ef49ec3d38d8370ae252520c28f1ab.zip
Praspel-63898995a0ef49ec3d38d8370ae252520c28f1ab.tar.gz
Praspel-63898995a0ef49ec3d38d8370ae252520c28f1ab.tar.bz2
Add coverage criteria (normal and exceptional).
Diffstat (limited to 'Iterator')
-rw-r--r--Iterator/Coverage/Structural.php58
1 files changed, 57 insertions, 1 deletions
diff --git a/Iterator/Coverage/Structural.php b/Iterator/Coverage/Structural.php
index 60c4300..dd6fb87 100644
--- a/Iterator/Coverage/Structural.php
+++ b/Iterator/Coverage/Structural.php
@@ -65,6 +65,20 @@ namespace Hoa\Praspel\Iterator\Coverage {
class Structural implements \Hoa\Iterator {
/**
+ * Criteria: normal (@requires and @ensures).
+ *
+ * @const int
+ */
+ const CRITERIA_NORMAL = 1;
+
+ /**
+ * Criteria: exceptional (@requires and @throwable).
+ *
+ * @const int
+ */
+ const CRITERIA_EXCEPTIONAL = 2;
+
+ /**
* Specification to cover.
*
* @var \Hoa\Praspel\Model\Specification object
@@ -72,6 +86,13 @@ class Structural implements \Hoa\Iterator {
protected $_specification = null;
/**
+ * Coverage criteria.
+ *
+ * @var \Hoa\Praspel\Iterator\Coverage\Structural int
+ */
+ protected $_criteria = 3; // CRITERIA_NORMAL | CRITERIA_EXCEPTIONAL
+
+ /**
* Stack (to manage backtracks, yields, etc.)
*
* @var \SplStack object
@@ -119,6 +140,9 @@ class Structural implements \Hoa\Iterator {
public function __construct ( \Hoa\Praspel\Model\Specification $specification ) {
$this->_specification = $specification;
+ $this->setCriteria(
+ static::CRITERIA_NORMAL | static::CRITERIA_EXCEPTIONAL
+ );
return;
}
@@ -159,7 +183,8 @@ class Structural implements \Hoa\Iterator {
if(true === $this->_up) {
- if('ensures' === $this->_post) {
+ if( 'ensures' === $this->_post
+ && 0 !== (static::CRITERIA_EXCEPTIONAL & $this->getCriteria())) {
$this->_up = false;
$this->_post = 'throwable';
@@ -251,6 +276,10 @@ class Structural implements \Hoa\Iterator {
$this->_stack = new \SplStack();
$this->_stack->push($this->_specification);
+ $this->_post = 0 !== (static::CRITERIA_NORMAL & $this->getCriteria())
+ ? 'ensures'
+ : 'throwable';
+
$this->_rewindCurrent();
return $this->current();
@@ -314,6 +343,33 @@ class Structural implements \Hoa\Iterator {
return null !== $this->_current;
}
+
+ /**
+ * Set coverage criteria.
+ *
+ * @access public
+ * @param int $criteria Criteria (please, see self::CRITERIA_*
+ * constants).
+ * @return int
+ */
+ public function setCriteria ( $criteria ) {
+
+ $old = $this->_criteria;
+ $this->_criteria = $criteria;
+
+ return $old;
+ }
+
+ /**
+ * get coverage criteria.
+ *
+ * @access public
+ * @return int
+ */
+ public function getCriteria ( ) {
+
+ return $this->_criteria;
+ }
}
}