aboutsummaryrefslogtreecommitdiff
path: root/src/clojure/contrib/test_contrib/test_trace.clj
blob: 4b283056a6e774e6597709e98216fee78a912e53 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
(ns clojure.contrib.test-contrib.test-trace
  (:use clojure.test
        [clojure.contrib trace str-utils]))

(deftrace call-myself [n]
  (when-not (< n 1)
    (call-myself (dec n))))

(deftest test-tracing-a-function-that-calls-itself
  (let [output (with-out-str (call-myself 1))]
    (is (re-find #"^TRACE t\d+: (call-myself 1)\nTRACE t\d+: |    (call-myself 0)\nTRACE t\d+: |    => nil\nTRACE t\d+: => nil$"
                 output))))