1. Rohin Shah
  2. Forth interpreter

Source

Forth interpreter / ANSForth / forth_tester.bak

#lang racket

(require "forth_base.rkt")

(define (displaynl arg)
  (display arg)
  (newline))

(let [(old_out (current-output-port))]
  (current-output-port (open-output-file "forth.tmp" #:exists 'truncate))
  (run-file "forth.test")
  (close-output-port (current-output-port))
  (current-output-port old_out)
  (displaynl "Tests executed"))

(define (check-equal-files a b [line 1])
  (let [(aline (read-line a))
        (bline (read-line b))]
    (cond [(and (eof-object? aline) (eof-object? bline))
           (displaynl "Tests checked")]
          [(or (eof-object? aline) (eof-object? bline))
           (displaynl (string-append "Line " (number->string line)
                                   ": Encountered end of file for only 1 file"))]
          [(equal? aline bline)
           (check-equal-files a b (+ line 1))]
          [else
           (displaynl (string-append "Line " (number->string line)
                                   ": Did not match"))
           (check-equal-files a b (+ line 1))])))

(let [(out (open-input-file "forth.out"))
      (tmp (open-input-file "forth.tmp"))]
  (check-equal-files out tmp))