(define (file=? f1 f2) ; compare two open files for (let loop ((c1 (read-char f1)) ; bytewise equality. (c2 (read-char f2))) (cond ((eof-object? c1) ; if both files EOF at the (eof-object? c2)) ; same time, we win, else ((eof-object? c2) ; the streams aren't equal. #f) (else (if (eqv? c1 c2) ; two equal chars? keep going (loop (read-char f1) (read-char f2)) #f))))) ; unequal characters: lose. (define testcases '("pi" "sieve" "cf" "r4rstest" "series" "ack")) (define (run-testcase t) ; run one testcase (let ((infile (string-append t ".scm")) (outfile (string-append t ".out")) (goodfile (string-append "vx-good/" t ".good"))) (with-output-to-file outfile ; capture output in a file and (lambda () (load infile))) (file=? (open-input-file outfile) ; compare it with good output (open-input-file goodfile)))) ; return #t if we pass (for-each ; run all testcases (lambda (testcase) (if (run-testcase testcase) (display "PASS: ") (display "FAIL: ")) (display testcase) (newline)) testcases)