evaluate expression only once for eval:check

This commit is contained in:
Matthew Flatt 2015-12-10 08:06:41 -07:00
parent 904f83ecf3
commit f637b94a61

View File

@ -259,19 +259,19 @@
(map (current-print) v))
(close-output-port out)
in)))])))
(define (do-ev s)
(with-handlers ([(lambda (x) (not (exn:break? x)))
(lambda (e)
(cons ((scribble-exn->string) e)
(get-outputs)))])
(cons (render-value (do-plain-eval ev s #t)) (get-outputs))))
(define (do-ev/expect s expect)
(define-values (val render+output)
(with-handlers ([(lambda (x) (not (exn:break? x)))
(lambda (e)
(cons ((scribble-exn->string) e)
(get-outputs)))])
(define val (do-plain-eval ev s #t))
(values val (cons (render-value val) (get-outputs)))))
(when expect
(let ([r (do-plain-eval ev s #t)]
[expect (do-plain-eval ev (car expect) #t)])
(unless (equal? r expect)
(let ([expect (do-plain-eval ev (car expect) #t)])
(unless (equal? val expect)
(raise-syntax-error 'eval "example result check failed" s))))
(do-ev s))
render+output)
(lambda (str)
(if (eval-results? str)
(list (map formatted-result (eval-results-contents str))