trace-test.ss
(module trace-test mzscheme
  
  (require (planet "test.ss" ("schematics" "schemeunit.plt" 2))
           (planet "io.ss" ("dherman" "io.plt" 1 6)))
  (require (lib "etc.ss")
           "trace.ss")
  
  (provide trace-tests)

  (define-traced (foo a b) (+ a b))
  (define-traced bar (lambda (a b) (+ a b)))
  (define-traced baz (opt-lambda ([a 1] [b 2]) (+ a b)))

  (define quux
    (lambda-traced (a b) (+ a b)))
  
  (define trace-tests
    (test-suite
     "All tests for trace"

     (test-case
      "define-traced function prints entry and exit"
      (check
       string=?
       (with-output-to-string (foo 1 2))
       "> (foo 1 2)\n< (foo 1 2)\n"))

     (test-case
      "define-traced lambda prints entry and exit"
      (check
       string=?
       (with-output-to-string (bar 1 2))
       "> (bar 1 2)\n< (bar 1 2)\n"))

     (test-case
      "define-traced opt-lambda prints entry and exit"
      (check
       string=?
       (with-output-to-string (baz))
       "> (baz 1* 2*)\n< (baz 1* 2*)\n"))

     (test-case
      "lambda-traced prints entry and exit"
      (check
       string=?
       (with-output-to-string (quux 1 2))
       "D,\"Entering traced lambda\",(1 2)\nD,\"Leaving traced lambda\",3\n"))
     ))
  )