aboutsummaryrefslogtreecommitdiffstats
path: root/AssertionChecker
diff options
context:
space:
mode:
authorIvan Enderlin <ivan.enderlin@hoa-project.net>2014-03-31 17:30:13 +0200
committerIvan Enderlin <ivan.enderlin@hoa-project.net>2014-03-31 17:30:13 +0200
commit62afa42d07ed15dad04a753c2c51a81108693fc1 (patch)
tree3f91cd79470116ebb064508bb83f227e6f2c0d46 /AssertionChecker
parentcc375fb2fd341d1165077cd0151bc0cbd1fea88b (diff)
downloadPraspel-62afa42d07ed15dad04a753c2c51a81108693fc1.zip
Praspel-62afa42d07ed15dad04a753c2c51a81108693fc1.tar.gz
Praspel-62afa42d07ed15dad04a753c2c51a81108693fc1.tar.bz2
Absent @throwable => failed.
Diffstat (limited to 'AssertionChecker')
-rw-r--r--AssertionChecker/Runtime.php90
1 files changed, 45 insertions, 45 deletions
diff --git a/AssertionChecker/Runtime.php b/AssertionChecker/Runtime.php
index e96b6ce..aceaaa1 100644
--- a/AssertionChecker/Runtime.php
+++ b/AssertionChecker/Runtime.php
@@ -193,6 +193,7 @@ class Runtime extends AssertionChecker {
if(0 < count($exceptions))
throw $exceptions;
+ $rootBehavior = $behavior instanceof \Hoa\Praspel\Model\Specification;
$numberOfArguments = count($arguments);
if($numberOfArguments < $numberOfRequiredArguments) {
@@ -205,6 +206,13 @@ class Runtime extends AssertionChecker {
throw $exceptions;
}
+ $_exceptions = true === $rootBehavior
+ ? $exceptions
+ : new \Hoa\Praspel\Exception\Group(
+ 'Behavior %s is broken.',
+ 3, $behavior->getIdentifier()
+ );
+
try {
// Invoke.
@@ -216,14 +224,6 @@ class Runtime extends AssertionChecker {
);
$arguments['\result'] = $return;
- $rootBehavior = $behavior instanceof \Hoa\Praspel\Model\Specification;
- $_exceptions = true === $rootBehavior
- ? $exceptions
- : new \Hoa\Praspel\Exception\Group(
- 'Behavior %s is broken.',
- 3, $behavior->getIdentifier()
- );
-
// Check normal postcondition.
if(true === $behavior->clauseExists('ensures')) {
@@ -245,59 +245,59 @@ class Runtime extends AssertionChecker {
'no normal postcondition has been specified (there is ' .
'no @ensures clause).', 3);
}
-
- if( 0 < count($_exceptions)
- && false === $rootBehavior) {
-
- $_behavior = $behavior;
-
- while( (null !== $_behavior = $_behavior->getParent())
- && !($_behavior instanceof \Hoa\Praspel\Model\Specification)) {
-
- $handle = new \Hoa\Praspel\Exception\Group(
- 'Behavior %s is broken.',
- 4, $_behavior->getIdentifier()
- );
- $handle[] = $_exceptions;
- $_exceptions = $handle;
- }
-
- $exceptions[] = $_exceptions;
- }
}
catch ( \Hoa\Praspel\Exception $internalException ) {
- $exceptions[] = new \Hoa\Praspel\Exception\Failure\InternalPrecondition(
+ $_exceptions[] = new \Hoa\Praspel\Exception\Failure\InternalPrecondition(
'The System Under Test has broken an internal contract.',
5, null, $internalException);
}
catch ( \Exception $exception ) {
- $_verdict = false;
$arguments['\result'] = $exception;
- do {
+ // Check exceptional postcondition.
+ if(true === $behavior->clauseExists('throwable')) {
- // Check exceptional postcondition.
- if(true === $behavior->clauseExists('throwable')) {
+ $throwable = $behavior->getClause('throwable');
+ $verdict &= $this->checkExceptionalClause(
+ $throwable,
+ $arguments
+ );
- $throwable = $behavior->getClause('throwable');
- $_verdict = $this->checkExceptionalClause(
- $throwable,
- $arguments
- );
- }
+ if(false == $verdict)
+ $_exceptions[] = new \Hoa\Praspel\Exception\Failure\Exceptional(
+ 'The exception %s has been unexpectedly thrown.',
+ 6, get_class($arguments['\result']), $exception);
+ }
+ else {
+
+ $verdict &= false;
+ $_exceptions[] = new \Hoa\Praspel\Exception\Failure\Exceptional(
+ 'The System Under Test cannot terminate exceptionally ' .
+ 'because no exceptional postcondition has been specified ' .
+ '(there is no @throwable clause).',
+ 6, array(), $exception);
+ }
+ }
- } while( false === $_verdict
- && null !== $behavior = $behavior->getParent());
+ if( 0 < count($_exceptions)
+ && false === $rootBehavior) {
- if(false === $_verdict)
- $exceptions[] = new \Hoa\Praspel\Exception\Failure\Exceptional(
- 'The exception %s has been unexpectedly thrown.',
- 6, get_class($arguments['\result']), $exception
+ $_behavior = $behavior;
+
+ while( (null !== $_behavior = $_behavior->getParent())
+ && !($_behavior instanceof \Hoa\Praspel\Model\Specification)) {
+
+ $handle = new \Hoa\Praspel\Exception\Group(
+ 'Behavior %s is broken.',
+ 4, $_behavior->getIdentifier()
);
+ $handle[] = $_exceptions;
+ $_exceptions = $handle;
+ }
- $verdict &= $_verdict;
+ $exceptions[] = $_exceptions;
}
if(0 < count($exceptions))