aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJustus Winter <[email protected]>2016-12-19 14:28:07 +0000
committerJustus Winter <[email protected]>2016-12-19 14:42:35 +0000
commitb852ac097f3dfe4e62c3d27e18a22f1b9f704530 (patch)
treea42c775c7fc53697a171bf9816690accf14e9d5d
parentgpgscm: Make exception handling more robust. (diff)
downloadlibgpg-error-b852ac097f3dfe4e62c3d27e18a22f1b9f704530.tar.gz
libgpg-error-b852ac097f3dfe4e62c3d27e18a22f1b9f704530.zip
gpgscm: Display location when assertions fail.
* tests/gpgscm/lib.scm (assert): Use location information if available. Signed-off-by: Justus Winter <[email protected]>
-rw-r--r--lib.scm15
1 files changed, 9 insertions, 6 deletions
diff --git a/lib.scm b/lib.scm
index fabbef8..6959aa4 100644
--- a/lib.scm
+++ b/lib.scm
@@ -18,13 +18,16 @@
;; along with this program; if not, see <http://www.gnu.org/licenses/>.
(macro (assert form)
- `(if (not ,(cadr form))
- (begin
- (display "Assertion failed: ")
- (write (quote ,(cadr form)))
- (newline)
- (exit 1))))
+ (let ((tag (get-tag form)))
+ `(if (not ,(cadr form))
+ (throw ,(if (pair? tag)
+ `(string-append ,(car tag) ":"
+ ,(number->string (+ 1 (cdr tag)))
+ ": Assertion failed: ")
+ "Assertion failed: ")
+ (quote ,(cadr form))))))
(assert #t)
+(assert (not #f))
(define (filter pred lst)
(cond ((null? lst) '())