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:
parent
8904b7a936
commit
1e42832af0
1 changed files with 14 additions and 12 deletions
|
@ -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"
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue