File: repl_test.clj

package info (click to toggle)
clj-stacktrace-clojure 0.2.7-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye, forky, sid, trixie
  • size: 124 kB
  • sloc: xml: 83; makefile: 29
file content (31 lines) | stat: -rw-r--r-- 803 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
(ns clj-stacktrace.repl-test
  (:use clojure.test)
  (:use clj-stacktrace.utils)
  (:use clj-stacktrace.repl))

(defmacro with-cascading-exception
  "Execute body in the context of a variable bound to an exception instance
  that includes a caused-by cascade."
  [binding-sym & body]
  `(try (first (lazy-seq (cons (/) nil)))
        (catch Exception e#
          (let [~binding-sym e#]
            ~@body))))

(deftest test-pst
  (with-cascading-exception e
    (is (with-out-str (pst e)))
    (binding [*e e]
      (is (with-out-str (pst))))))

(deftest test-pst-str
  (with-cascading-exception e
    (is (pst-str e))
    (binding [*e e]
      (is (pst-str)))))

(deftest test-pst+
  (with-cascading-exception e
    (is (with-out-str (pst+ e)))
    (binding [*e e]
      (is (with-out-str (pst+))))))