private/term-test.ss
(module term-test mzscheme
  (require "term.ss"
           "matcher.ss"
           "test-util.ss")

  (reset-count)
  (test (term 1) 1)
  (test (term (1 2)) (list 1 2))
  (test (term (1 ,(+ 1 1))) (list 1 2))
  (test (term-let ([x 1]) (term (x x))) (list 1 1))
  (test (term-let ([(x ...) (list 1 2 3)]) (term ((y x) ...))) '((y 1) (y 2) (y 3)))
  (test (term hole) (make-hole #f))
  (test (term (hole #f)) (make-hole #f))
  (test (term (hole hole-id)) (make-hole 'hole-id))
  

  (test (term-let-fn ((f (lambda (q) `(y ,q))))
                     (term (f (zzzz))))
        (term (y (zzzz))))
  
  (test (term-let-fn ((f add1))
                     (term (f 2)))
        (term 3))
  
  (test (with-syntax ([((x ...) ...) (list (list 1 1) (list 2 2) (list 3 3))])
          (term-let-fn ((f (λ (x) x)))
                       (term ((qq (f x) ...) ...))))
        (term ((qq 1 1) (qq 2 2) (qq 3 3))))
  
  (test (term-let-fn ((f (lambda (x) x)))
                     (term (f hole)))
        (term hole))
  
  (test (term-let-fn ((f (lambda (q) `(y ,q))))
                     (term-let-fn ((g (lambda (x) `(ff ,x))))
                                  (term (g (f (zzzz))))))
        (term (ff (y (zzzz)))))
  
  (test (term-let-fn ((f (lambda (q) `(y ,q))))
                     (term-let-fn ((g (lambda (x) `(ff ,x))))
                                  (term (f (g (f (zzzz)))))))
        (term (y (ff (y (zzzz))))))

  (test (term-let ([x 1])
                  (term (x . y)))
        (term (1 . y)))
  
  (test (term-let ([(x ...) (list 3 2 1)])
                  (term (x ... . y)))
        (term (3 2 1 . y)))
  
  (test (term-let ([(x . y) (cons 1 2)])
                  (term (x y)))
        (term (1 2)))
  
  (printf "term-test.ss: all ~a tests passed.\n" tests))