1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-06-09 21:40:33 +02:00

Convert test-suite/tests/exceptions.test to use hygienic macros.

* test-suite/tests/exceptions.test (push): New syntax parameter.
  (throw-test): Convert to a syntax-rules macro, using syntax parameters
  to support the otherwise-unhygienic use of "push".
This commit is contained in:
Chris K. Jester-Young 2013-10-27 17:31:38 -04:00 committed by Mark H Weaver
parent 8904b7a936
commit 1e42832af0

View file

@ -18,18 +18,20 @@
(use-modules (test-suite lib)) (use-modules (test-suite lib))
(define-macro (throw-test title result . exprs) (define-syntax-parameter push
`(pass-if ,title (lambda (stx)
(equal? ,result (syntax-violation 'push "push used outside of throw-test" stx)))
(letrec ((stack '())
(push (lambda (val) (define-syntax-rule (throw-test title result expr ...)
(set! stack (cons val stack))))) (pass-if title
(begin ,@exprs) (equal? result
;;(display ,title) (let ((stack '()))
;;(display ": ") (syntax-parameterize ((push (syntax-rules ()
;;(write (reverse stack)) ((push val)
;;(newline) (set! stack (cons val stack))))))
(reverse stack))))) expr ...
;;(format #t "~a: ~s~%" title (reverse stack))
(reverse stack))))))
(with-test-prefix "throw/catch" (with-test-prefix "throw/catch"