aboutsummaryrefslogtreecommitdiff
path: root/src/clojure/contrib/test_contrib/test_trace.clj
blob: dee7122a5b178a15b93c0340e7cbbe24f8dc4d58 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
(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))))

(deftest dotrace-on-core
  (let [output (with-out-str (dotrace [mod] (mod 11 5)))]
    (is (re-find #"\(mod 11 5\)" output))))