Adding test printing tests

This commit is contained in:
Jay McCarthy 2010-10-15 13:01:48 -06:00
parent e8ceade2a5
commit f6fbc85d1b
2 changed files with 35 additions and 1 deletions

View File

@ -0,0 +1,19 @@
#lang plai/mutator
(allocator-setup "../good-collectors/good-collector.ss" 400)
(print-only-errors #f)
(define lst (cons 1 (cons 2 (cons 3 empty))))
(test/value=? lst '(1 2 3))
(define (length lst)
(if (empty? lst)
0
(add1 (length (rest lst)))))
(test/value=? (length '(hello goodbye)) 2)
(define tail (cons 1 empty))
(define head (cons 4 (cons 3 (cons 2 tail))))
(set-rest! tail head)
(test/location=? head (rest tail))
(test/location=? head tail)

View File

@ -20,13 +20,18 @@
(command-line #:program "run-test"
#:once-each ["-g" "Enable running good mutators" (run-good? #t)])
(define (drop-first-line e)
(regexp-replace "^[^\n]+\n" e ""))
(define-syntax-rule (capture-output e)
(drop-first-line (with-output-to-string (λ () e))))
(test
(if (run-good?)
(for ([m (in-directory (build-path here "good-mutators") #rx"rkt$")])
(test
(test-mutator m)))
(void))
(for ([m (in-directory (build-path here "bad-mutators") #rx"rkt$")])
#;(for ([m (in-directory (build-path here "bad-mutators") #rx"rkt$")])
(test
(test-mutator m) =error> #rx""))
@ -37,4 +42,14 @@
(test-mutator (build-path here "other-mutators" "top.rkt"))
=error>
#rx"unbound identifier in module in: frozzle"
(capture-output (test-mutator (build-path here "other-mutators" "printing.rkt")))
=>
#<<END
(good lst '(1 2 3) '(1 2 3) "at line 6")
(good (length (quote (hello goodbye))) 2 2 "at line 13")
(good (heap-loc head) 62 62 "at line 18")
(bad (heap-loc head) 62 47 "at line 19")
END
)