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