diff options
author | Ivan Enderlin <ivan.enderlin@hoa-project.net> | 2013-05-27 18:05:42 +0200 |
---|---|---|
committer | Ivan Enderlin <ivan.enderlin@hoa-project.net> | 2013-05-27 18:05:42 +0200 |
commit | 186c66d8892dc531b893907723b77d31a91e82d1 (patch) | |
tree | eb9b9b21a9444562b7279c0efd1eaf90d1f7a92c /Iterator | |
parent | 13f5cfcbf59ecffc4171cbde7eb4ee2612cd3004 (diff) | |
download | Praspel-186c66d8892dc531b893907723b77d31a91e82d1.zip Praspel-186c66d8892dc531b893907723b77d31a91e82d1.tar.gz Praspel-186c66d8892dc531b893907723b77d31a91e82d1.tar.bz2 |
Propagate combinatorics to all clauses.
For “domain” coverage criterion, the combinatorics is now applied to all
clauses at the same time.
Diffstat (limited to 'Iterator')
-rw-r--r-- | Iterator/Coverage/Structural.php | 38 |
1 files changed, 25 insertions, 13 deletions
diff --git a/Iterator/Coverage/Structural.php b/Iterator/Coverage/Structural.php index b9a6b98..02c9156 100644 --- a/Iterator/Coverage/Structural.php +++ b/Iterator/Coverage/Structural.php @@ -59,9 +59,9 @@ from('Hoa') -> import('Iterator.Recursive.~') /** - * \Hoa\Iterator\Multiple + * \Hoa\Iterator\Demultiplexer */ --> import('Iterator.Multiple') +-> import('Iterator.Demultiplexer') /** * \Hoa\Iterator\Recursive\Mock @@ -398,25 +398,37 @@ class Structural implements \Hoa\Iterator\Recursive { */ public function getChildren ( ) { - $pre = array(); - $post = array(); - $iterator = new \Hoa\Iterator\Multiple( - \Hoa\Iterator\Multiple::MIT_NEED_ANY - | \Hoa\Iterator\Multiple::MIT_KEYS_ASSOC - ); + $variables = array(); foreach($this->_current['pre'] as $clause) foreach($clause->getLocalVariables() as $variable) - $pre[] = $variable; + $variables[] = $variable; foreach($this->_current['post'] as $clause) foreach($clause->getLocalVariables() as $variable) - $post[] = $variable; + $variables[] = $variable; + + return new \Hoa\Iterator\Recursive\Mock( + new \Hoa\Iterator\Demultiplexer( + new Domain($variables), + function ( $current ) { + + $out = array('pre' => array(), 'post' => array()); + + foreach($current as $name => $variable) { - $iterator->attachIterator(new Domain($pre), 'pre', array()); - $iterator->attachIterator(new Domain($post), 'post', array()); + $clause = $variable->getHolder()->getClause(); - return new \Hoa\Iterator\Recursive\Mock($iterator); + if($clause instanceof \Hoa\Praspel\Model\Requires) + $out['pre'][$name] = $variable; + else + $out['post'][$name] = $variable; + } + + return $out; + } + ) + ); } } |