aboutsummaryrefslogtreecommitdiffstats
path: root/Praspel.php
diff options
context:
space:
mode:
authorIvan Enderlin <ivan.enderlin@hoa-project.net>2013-05-30 12:25:12 +0200
committerIvan Enderlin <ivan.enderlin@hoa-project.net>2013-05-30 12:25:12 +0200
commitd0e94fb667567164e3d1c1ea20c001fdbc7a2b00 (patch)
treecce08af08c205ffbf9bf386f9a1956effb08524d /Praspel.php
parent4c44b40429c2d15895cfb77d08d7c78781086a16 (diff)
downloadPraspel-d0e94fb667567164e3d1c1ea20c001fdbc7a2b00.zip
Praspel-d0e94fb667567164e3d1c1ea20c001fdbc7a2b00.tar.gz
Praspel-d0e94fb667567164e3d1c1ea20c001fdbc7a2b00.tar.bz2
RAC is able to auto-generate data (early draft).
Diffstat (limited to 'Praspel.php')
-rw-r--r--Praspel.php23
1 files changed, 18 insertions, 5 deletions
diff --git a/Praspel.php b/Praspel.php
index 3a89a44..6724237 100644
--- a/Praspel.php
+++ b/Praspel.php
@@ -86,7 +86,7 @@ class Praspel {
*
* @var \Hoa\Praspel array
*/
- protected $_data = array();
+ protected $_data = null;
/**
* Callable to validate and verify.
@@ -125,16 +125,19 @@ class Praspel {
$callable = $this->getCallable();
$reflection = $callable->getReflection();
- $variables = $this->getData();
$arguments = array();
+ $data = $this->getData();
+
+ if(null === $data)
+ $data = $this->generateData();
foreach($reflection->getParameters() as $parameter) {
$name = $parameter->getName();
- if(true === array_key_exists($name, $variables)) {
+ if(true === array_key_exists($name, $data)) {
- $arguments[$name] = &$variables[$name];
+ $arguments[$name] = &$data[$name];
continue;
}
@@ -165,7 +168,7 @@ class Praspel {
$return = $callable->distributeArguments($arguments);
$ensures = $specification->getClause('ensures');
- if(isset($ensures['result']))
+ if(isset($ensures['\result']))
$ensures['\result'] = $return;
$postcondition = true;
@@ -205,6 +208,16 @@ class Praspel {
return $this->_specification;
}
+ public function generateData ( ) {
+
+ $data = array();
+
+ foreach($this->_specification->getClause('requires') as $name => $variable)
+ $data[$name] = $variable->sample();
+
+ return $this->_data = $data;
+ }
+
/**
* Set data.
*