(module top (lib "eopl.ss" "eopl") ;; top level module. Loads all required pieces and runs the test ;; suite. (require "drscheme-init.scm") (require "data-structures.scm") ; for expval constructors (require "lang.scm") ; for scan&parse (require "interp.scm") ; for value-of-program (require "tests.scm") ; for test-list (require "check-modules.scm") (require "equal-types.scm") (provide (all-defined)) (provide (all-from "interp.scm")) (provide (all-from "lang.scm")) ;;;;;;;;;;;;;;;; interface to test harness ;;;;;;;;;;;;;;;; ;; run : string -> expval (define run (lambda (string) (value-of-program (scan&parse string)))) ;; run-all : () -> unspecified ;; runs all the tests in test-list, comparing the results with ;; equal-answer? (define run-all (lambda () (run-tests! run equal-answer? tests-for-run))) (define equal-answer? (lambda (ans correct-ans) (equal? ans (sloppy->expval correct-ans)))) (define sloppy->expval (lambda (sloppy-val) (cond ((number? sloppy-val) (num-val sloppy-val)) ((boolean? sloppy-val) (bool-val sloppy-val)) (else (eopl:error 'sloppy->expval "Can't convert sloppy value to expval: ~s" sloppy-val))))) ;; run-one : symbol -> expval ;; (run-one sym) runs the test whose name is sym (define run-one (lambda (test-name) (let ((the-test (assoc test-name tests-for-run))) (cond (the-test => (lambda (test) (run (cadr test)))) (else (eopl:error 'run-one "no such test: ~s" test-name)))))) ; (stop-after-first-error #t) ; (run-all) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; check : string -> external-type (define check (lambda (string) (type-to-external-form (type-of-program (scan&parse string))))) ;; check-all : () -> unspecified ;; checks all the tests in test-list, comparing the results with ;; equal-types? (define check-all (lambda () (run-tests! check equal-types? tests-for-check))) ;; check-one : symbol -> expval ;; (check-one sym) checks the test whose name is sym (define check-one (lambda (test-name) (let ((the-test (assoc test-name tests-for-check))) (cond (the-test => (lambda (test) (check (cadr test)))) (else (eopl:error 'check-one "no such test: ~s" test-name)))))) ; (stop-after-first-error #t) (check-all) ;(check-one 'modules-check-shadowing-1.9) )