diff options
author | Ivan Enderlin <ivan.enderlin@hoa-project.net> | 2013-06-13 01:36:05 +0200 |
---|---|---|
committer | Ivan Enderlin <ivan.enderlin@hoa-project.net> | 2013-06-13 01:36:05 +0200 |
commit | 591d73d9ff931517433614473f0ca651d13b1cad (patch) | |
tree | f028a2bc12d409e6603b9e9fb713858c98e82695 /Praspel.php | |
parent | 7219b89590d9da200b70ab73cda951da21b6534e (diff) | |
download | Praspel-591d73d9ff931517433614473f0ca651d13b1cad.zip Praspel-591d73d9ff931517433614473f0ca651d13b1cad.tar.gz Praspel-591d73d9ff931517433614473f0ca651d13b1cad.tar.bz2 |
The RAC now verifies invariants.
Diffstat (limited to 'Praspel.php')
-rw-r--r-- | Praspel.php | 38 |
1 files changed, 36 insertions, 2 deletions
diff --git a/Praspel.php b/Praspel.php index 4fd8d58..54d4bed 100644 --- a/Praspel.php +++ b/Praspel.php @@ -203,6 +203,21 @@ class Praspel { $arguments[$name] = $parameter->getDefaultValue(); } + // Check invariant. + if(true === $specification->clauseExists('invariant')) { + + $invariant = $specification->getClause('invariant'); + $verdict &= $this->checkClause( + $invariant, + $arguments, + $exceptions, + __NAMESPACE__ . '\Exception\Failure\Invariant' + ); + + if(0 < count($exceptions)) + throw $exceptions; + } + // Check requires and behaviors. $behavior = $specification; $verdict &= $this->checkBehavior( @@ -268,6 +283,21 @@ class Praspel { if(0 < count($exceptions)) throw $exceptions; + // Check invariant. + if(true === $specification->clauseExists('invariant')) { + + $invariant = $specification->getClause('invariant'); + $verdict &= $this->checkClause( + $invariant, + $arguments, + $exceptions, + __NAMESPACE__ . '\Exception\Failure\Invariant' + ); + + if(0 < count($exceptions)) + throw $exceptions; + } + return (bool) $verdict; } @@ -381,9 +411,13 @@ class Praspel { if(false === $_verdict) $exceptions[] = new $exception( - 'Variable %s does not verify the constraint %s.', + 'Variable %s does not verify the constraint @%s %s.', 5, - array($name, $this->getVisitorPraspel()->visit($variable))); + array( + $name, + $clause->getName(), + $this->getVisitorPraspel()->visit($variable) + )); $verdict = $_verdict && $verdict; } |