;; Basic checks for the beginner language. Error messages really ;; should be inspected manually, but there's some support for ;; automatic checking. ;; Limitations of this test suite: ;; - It doesn't check reader-level parameterization, such as use of quotes ;; - It doesn't check format of printed results ;; - It doesn't check the absence of MzScheme forms ;; Don't try to run other tests from the test suite after loading this ;; one into a particular namespace. ;; See also htdp-image.ss, which must be loaded into MrEd (but is in this ;; directory anyway) ;; Tests that apply to all languages go in beg-adv.ss. ;; Tests that apply only to beginner through intermediate go in beg-intm.ss, ;; and so on. ;; Writing tests: ;; ;; (htdp-test ) ;; checks a run-time result; is ;; an expression evaluated at the top level, ;; and is put into a module and evaluated; ;; is usually a symbol, and it is used only for ;; naming the test in output ;; ;; (htdp-err/rt-test ) ;; (htdp-err/rt-test ) ;; (htdp-err/rt-test ) ;; checks for a run-time error by putting into a ;; module and evaluting; if is supplied, the ;; predicate must produce #t for the resulting exception; ;; if is supplied, the exception ;; message string must match the regexp ;; ;; (htdp-syntax-test #') ;; (htdp-syntax-test #' ) ;; check for a syntax error, putting into a module; ;; if is supplied, the syntax error ;; message must match the regexp ;; ;; (htdp-top ) ;; imperatively adds an expression to be included into ;; test modules ;; (htdp-top-pop ) ;; removes the last added expressions ;; (load-relative "loadtest.ss") ;; Check that expansion doesn't introduce non-equal ids that ;; claim to be "original" at the same place (let loop ([x (expand #'(module m (lib "htdp-beginner.ss" "lang") (define (f x) x)))]) (let ([orig-ids (let loop ([x x]) (cond [(identifier? x) (if (syntax-original? x) (list x) null)] [(null? x) null] [(pair? x) (append (loop (car x)) (loop (cdr x)))] [(syntax? x) (loop (syntax-e x))] [else null]))]) (for-each (lambda (id1) (for-each (lambda (id2) (when (and (= (syntax-position id1) (syntax-position id2)) (not (free-identifier=? id1 id2))) (error 'original "mismatch: ~e ~e" id1 id2))) orig-ids)) orig-ids))) ;; Don't need these: (define no-extra-if-tests? #t) (require (only-in mzscheme exn:fail? exn:fail:contract?)) (define current-htdp-lang 'lang/htdp-beginner) (load-relative "htdp-test.ss") (require (lib "htdp-beginner.ss" "lang")) (load-relative "beg-adv.ss") (load-relative "beg-intml.ss") (load-relative "beg-intm.ss") (load-relative "beg-bega.ss") (htdp-syntax-test #'quote) (htdp-syntax-test #''1) (htdp-syntax-test #''"hello") (htdp-syntax-test #''(1 2)) (htdp-syntax-test #'''a) (report-errs)