racket/collects/tests/errortrace/wrap.rkt
Matthew Flatt 9f5ad021f1 fix errortrace
The `eq?'ness of syntax objects used to reconstruct the result
 was broken by disarming. The solution is to reconstruct based
 on the disarmed syntax object instead of the original.

 Merge to 5.1.2.
(cherry picked from commit 0f61d62ea1)
2011-07-19 11:12:48 -04:00

26 lines
1.0 KiB
Racket

#lang racket/base
(define err-stx #'(error '"bad"))
(define (try expr)
(define out-str
(parameterize ([current-namespace (make-base-namespace)])
(parameterize ([current-compile (dynamic-require 'errortrace/errortrace-lib
'errortrace-compile-handler)]
[error-display-handler (dynamic-require 'errortrace/errortrace-lib
'errortrace-error-display-handler)])
(let ([o (open-output-string)])
(parameterize ([current-error-port o])
(call-with-continuation-prompt
(lambda ()
(eval expr))))
(get-output-string o)))))
(unless (regexp-match? (regexp-quote (format "~s" (syntax->datum err-stx)))
out-str)
(error 'test "not in context for: ~s" (syntax->datum expr))))
(try #`(begin (module m racket/base #,err-stx) (require 'm)))
(try err-stx)
(try #`(syntax-case 'a ()
(_ #,err-stx)))