tests/record-case-tests.ss
;; To run the tests:
;;
;;   (require (planet "tests/record-case-tests.ss" ("dvanhorn" "record-case.plt" 1 0))
;;            (planet "text-ui.ss" ("schematics" "schemeunit.plt" 2 8)))
;;   (test/text-ui record-case-tests)

(module record-case-tests mzscheme
  (provide record-case-tests)
  (require "../record-case.ss")
  (require (planet "test.ss" ("schematics" "schemeunit.plt" 2 8)))
  
  (define test
    (lambda (e)
      (record-case e
	(a (b c) (list b c))
	(b c c)
	(c (a . b) (list a b))
	(else 'whatever))))
  
  (define record-case-tests
    (test-suite
     "Tests for record-case"
     
     (test-equal? 
      "Simple pattern matching with formal list pattern."
      (test '(a 1 2))
      '(1 2))
     
     (test-equal?
      "Simple pattern matching with var-arg pattern."
      (test '(b 1 2 3 4))
      '(1 2 3 4))
     
     (test-equal?
      "Simple pattern matching with rest pattern."
      (test '(c 1 2 3 4))
      '(1 (2 3 4)))
     
     (test-equal?
      "Simple pattern matching with else clause."
      (test '(d 1 2 3 4))
      'whatever)
     
     (test-equal?
      "Pattern matching with excess elements succeeds."
      (test '(a 1 2 3 4))
      '(1 2))
     
     (test-exn
      "Pattern matching with lack of elements fails."
      exn:fail?
      (lambda ()
        (test '(a 1))))
     ))
  
  ) ; end of module record-case-tests