Fixing broken rackunit display tests

original commit: 169a9ea28d6e3e4e3f4642b87ddf7007dde264a0
This commit is contained in:
Jay McCarthy 2013-03-26 06:08:01 -06:00
parent 38f8b0cb3d
commit b7b42f0226
2 changed files with 26 additions and 7 deletions

View File

@ -84,7 +84,7 @@
;; Strip any check-params? is there is an ;; Strip any check-params? is there is an
;; actual/expected check-info in the same stack frame. A ;; actual/expected check-info in the same stack frame. A
;; stack frame is delimited by occurrence of a check-name? ;; stack frame is delimited by occurrence of a check-name?
(define (strip-redundant-params stack) (define (strip-redundant-params start-stack)
(define (binary-check-this-frame? stack) (define (binary-check-this-frame? stack)
(let loop ([stack stack]) (let loop ([stack stack])
(cond (cond
@ -92,11 +92,11 @@
[(check-name? (car stack)) #f] [(check-name? (car stack)) #f]
[(check-actual? (car stack)) #t] [(check-actual? (car stack)) #t]
[else (loop (cdr stack))]))) [else (loop (cdr stack))])))
(let loop ([stack stack]) (let loop ([stack start-stack])
(cond (cond
[(null? stack) null] [(null? stack) null]
[(check-params? (car stack)) [(check-params? (car stack))
(if (binary-check-this-frame? stack) (if (binary-check-this-frame? start-stack)
(loop (cdr stack)) (loop (cdr stack))
(cons (car stack) (loop (cdr stack))))] (cons (car stack) (loop (cdr stack))))]
[else (cons (car stack) (loop (cdr stack)))]))) [else (cons (car stack) (loop (cdr stack)))])))

View File

@ -116,6 +116,24 @@
(display-exn exn))] (display-exn exn))]
[else (void)])) [else (void)]))
(define (sort-stack l)
(sort l <
#:key
(λ (info)
(cond
[(check-name? info)
0]
[(check-location? info)
1]
[(check-params? info)
2]
[(check-actual? info)
3]
[(check-expected? info)
4]
[else
5]))))
(define (textui-display-check-info-stack stack [verbose? #f]) (define (textui-display-check-info-stack stack [verbose? #f])
(for-each (for-each
(lambda (info) (lambda (info)
@ -149,9 +167,10 @@
(void)] (void)]
[else [else
(display-check-info info)])) (display-check-info info)]))
(if verbose? (sort-stack
stack (if verbose?
(strip-redundant-params stack)))) stack
(strip-redundant-params stack)))))
;; display-verbose-check-info : test-result -> void ;; display-verbose-check-info : test-result -> void
(define (display-verbose-check-info result) (define (display-verbose-check-info result)
@ -172,7 +191,7 @@
(display ": ") (display ": ")
(write (check-info-value info)))) (write (check-info-value info))))
(newline)) (newline))
stack))) (sort-stack stack))))
((test-error? result) ((test-error? result)
(display-exn (test-error-result result))) (display-exn (test-error-result result)))
(else (else