gpgscm: Display location when assertions fail.
authorJustus Winter <justus@g10code.com>
Mon, 19 Dec 2016 14:28:07 +0000 (15:28 +0100)
committerJustus Winter <justus@g10code.com>
Mon, 19 Dec 2016 14:42:35 +0000 (15:42 +0100)
* tests/gpgscm/lib.scm (assert): Use location information if
available.

Signed-off-by: Justus Winter <justus@g10code.com>
tests/gpgscm/lib.scm

index fabbef8..6959aa4 100644 (file)
 ;; 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) '())