evaluate expression only once for eval:check
This commit is contained in:
parent
904f83ecf3
commit
f637b94a61
|
@ -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))
|
||||
|
|
Loading…
Reference in New Issue
Block a user