;; Import the Racket unit testing package. for details, see ;; http://docs.racket-lang.org/rackunit/. If this file is named ;; hw6test.ss, you can run it from the unix command line on gl like ;; ;; mzscheme -f hw6test.ss ;; require the racket module for unit testing and its text user ;; interface (require rackunit rackunit/text-ui) ;; Load your HW6 file (load "hw6.ss") ;; Define some tests for the lambda expressions (define lambda-tests (test-suite "tests for chop and unchop" ;; these should all produce a correct result (test-equal? "L1" (L1) 0) (test-equal? "L2" (L2 "aaa" "bbb") "aaa") (test-equal? "L2" (L2 "bbb" "bbb") "bbb") (test-equal? "L2" (L2 "bbb" "aaa") "aaa") (test-equal? "L3" ((L3 <) 4 3) #t) (test-equal? "L3" ((L3 <) 3 4) #f) (test-equal? "L3" ((L3 <) 3 3) #t) (test-equal? "L3" ((L3 (L3 <)) 3 4) #t) (test-equal? "L3" ((L3 (L3 <)) 4 3) #f) )) ;; Define some tests for unique-atoms (define unique-atoms-tests (test-suite "tests for unique-atoms" (test-equal? "" (unique-atoms '()) null) (test-equal? "" (unique-atoms '(()(())())) null) (test-equal? "" (sort (unique-atoms '(1 2 3)) <) '(1 2 3)) (test-equal? "" (sort (unique-atoms '(3 2 1)) <) '(1 2 3)) (test-equal? "" (sort (unique-atoms '(1 1 2 3 2 3 1)) <) '(1 2 3)) (test-equal? "" (sort (unique-atoms '((1) ((2)) (((3))))) <) '(1 2 3)) (test-equal? "" (sort (unique-atoms '((1) 1 ((2) 2) (((3) () 3) 2) 1)) <) '(1 2 3)) )) ;; Run the test suites and report the results (printf "\nRunning lambda tests\n") (run-tests lambda-tests) (printf "\nRunning unique-atoms tests\n") (run-tests unique-atoms-tests) ;; We're done!