aboutsummaryrefslogtreecommitdiffstats
path: root/Praspel.php
diff options
context:
space:
mode:
authorIvan Enderlin <ivan.enderlin@hoa-project.net>2013-06-12 17:50:15 +0200
committerIvan Enderlin <ivan.enderlin@hoa-project.net>2013-06-12 17:50:15 +0200
commitb6b2a38e442ed64ac8ea6b0edeb1638e4caa1ef9 (patch)
tree3a22724babddb346a1f91a4688cac57286f0c739 /Praspel.php
parent982b920447951ee095456d1714b00f7de2d47b85 (diff)
downloadPraspel-b6b2a38e442ed64ac8ea6b0edeb1638e4caa1ef9.zip
Praspel-b6b2a38e442ed64ac8ea6b0edeb1638e4caa1ef9.tar.gz
Praspel-b6b2a38e442ed64ac8ea6b0edeb1638e4caa1ef9.tar.bz2
Add internal precondition failure support.
Diffstat (limited to 'Praspel.php')
-rw-r--r--Praspel.php18
1 files changed, 12 insertions, 6 deletions
diff --git a/Praspel.php b/Praspel.php
index ce6d883..4fd8d58 100644
--- a/Praspel.php
+++ b/Praspel.php
@@ -243,6 +243,12 @@ class Praspel {
} while(null !== $behavior = $behavior->getParent());
}
+ catch ( Exception $internalException ) {
+
+ $exceptions[] = new Exception\Failure\InternalPrecondition(
+ 'The System Under Test has broken an internal contract.',
+ 2, null, $internalException);
+ }
catch ( \Exception $exception ) {
// Check exceptional postcondition.
@@ -307,7 +313,7 @@ class Praspel {
$_exceptions = new Exception\Group(
'Behavior %s does not verify data.',
- 2, $_behavior->getIdentifier());
+ 3, $_behavior->getIdentifier());
$_verdict = $this->checkBehavior(
$_behavior,
@@ -366,7 +372,7 @@ class Praspel {
if(false === array_key_exists($name, $data)) {
$exceptions[] = new $exception(
- 'Variable %s has no value and is required.', 3, $name);
+ 'Variable %s has no value and is required.', 4, $name);
continue;
}
@@ -376,7 +382,7 @@ class Praspel {
if(false === $_verdict)
$exceptions[] = new $exception(
'Variable %s does not verify the constraint %s.',
- 4,
+ 5,
array($name, $this->getVisitorPraspel()->visit($variable)));
$verdict = $_verdict && $verdict;
@@ -431,7 +437,7 @@ class Praspel {
if(false === $verdict)
$exceptions[] = new $exception(
'The exception %s has been thrown and it is not specified.',
- 5, array(get_class($data['\result'])));
+ 6, array(get_class($data['\result'])));
return $verdict;
}
@@ -590,14 +596,14 @@ class Praspel {
if(0 === $i)
throw new Exception\Generic(
'Not able to extract Praspel from the following ' .
- 'comment:' . "\n" . '%s', 5, $comment);
+ 'comment:' . "\n" . '%s', 6, $comment);
$i = preg_match_all('#^[\s\*]*\s*\*\s?([^\n]*)$#m', $matches[1], $maatches);
if(0 === $i)
throw new Exception\Generic(
'Not able to extract Praspel from the following ' .
- 'comment:' . "\n" . '%s', 6, $comment);
+ 'comment:' . "\n" . '%s', 7, $comment);
return trim(implode("\n", $maatches[1]));
}