Skip to content

Commit

Permalink
fixup! Break into the debugger upon error
Browse files Browse the repository at this point in the history
Rework evaluation-strategy
  • Loading branch information
foretspaisibles committed Apr 12, 2024
1 parent 8b5a3f8 commit ae06df9
Showing 1 changed file with 52 additions and 42 deletions.
94 changes: 52 additions & 42 deletions src/testcase.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -320,48 +320,58 @@ instead of returning normally."))
(defun instrument-assertion-1 (&key name form type argument-names argument-lambdas assertion-lambda)
"Supervise the execution of ARGUMENTS-LAMBDA and ASSERTION-LAMBDA."
(labels ((evaluation-strategy-1 (argument-condition argument-values)
(when argument-condition
(signal
'assertion-condition
:path *testcase-path*
:name name
:argument-names argument-names
:argument-values argument-values
:form form
:type type
:condition (first argument-condition))
(return-from evaluation-strategy-1))
(multiple-value-bind (success-p description)
(handler-case (funcall assertion-lambda argument-values)
(serious-condition (unexpected-condition)
(signal
'assertion-condition
:path *testcase-path*
:name name
:argument-names argument-names
:argument-values argument-values
:form form
:type type
:condition unexpected-condition)
(return-from evaluation-strategy-1)))
(cond
((not success-p)
(signal 'assertion-failure
:path *testcase-path*
:name name
:argument-names argument-names
:argument-values argument-values
:form form
:type type
:description description))
(t
(signal 'assertion-success
:path *testcase-path*
:name name
:argument-names argument-names
:argument-values argument-values
:form form
:type type)))))
(flet ((signal-argument-condition (condition)
(signal
'assertion-condition
:path *testcase-path*
:name name
:argument-names argument-names
:argument-values argument-values
:form form
:type type
:condition condition))
(signal-unexpected-condition (condition)
(signal
'assertion-condition
:path *testcase-path*
:name name
:argument-names argument-names
:argument-values argument-values
:form form
:type type
:condition condition))
(signal-failure (description)
(signal
'assertion-failure
:path *testcase-path*
:name name
:argument-names argument-names
:argument-values argument-values
:form form
:type type
:description description))
(signal-success ()
(signal
'assertion-success
:path *testcase-path*
:name name
:argument-names argument-names
:argument-values argument-values
:form form
:type type)))
(when argument-condition
(signal-argument-condition (first argument-condition))
(return-from evaluation-strategy-1))
(multiple-value-bind (success-p description)
(handler-case (funcall assertion-lambda argument-values)
(serious-condition (unexpected-condition)
(signal-unexpected-condition unexpected-condition)
(return-from evaluation-strategy-1)))
(cond
((not success-p)
(signal-failure description))
(t
(signal-success))))))
(evaluation-strategy (argument-values)
(evaluation-strategy-1
(member-if (lambda (object) (typep object 'condition)) argument-values)
Expand Down

0 comments on commit ae06df9

Please sign in to comment.