gpgscm: Display location when assertions fail.

* tests/gpgscm/lib.scm (assert): Use location information if
available.

Signed-off-by: Justus Winter <justus@g10code.com>
This commit is contained in:
Justus Winter 2016-12-19 15:28:07 +01:00
parent df00745d6e
commit 3949cbd112
1 changed files with 9 additions and 6 deletions

View File

@ -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) '())