Skip to content

Commit 44c0423

Browse files
committed
add test
1 parent f1df0a6 commit 44c0423

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

test/sci/error_test.cljc

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,25 @@
5959
"user - NO_SOURCE_PATH:1:34")
6060
formatted))))))
6161

62+
(deftest current-stacktrace-test
63+
(testing "lexical stack with fn - includes line/column"
64+
(let [stacktrace (sci/binding [sci/file "test.clj"]
65+
(eval-string "((fn outer [] ((fn inner [] (sci.impl/current-stacktrace)))))"))]
66+
(is (= [{:ns 'user, :name 'outer, :file "test.clj", :line 1, :column 2}
67+
{:ns 'user, :name 'inner, :file "test.clj", :line 1, :column 16}]
68+
stacktrace))))
69+
(testing "lexical stack with defn - file but no line/column (macro expansion)"
70+
(let [stacktrace (sci/binding [sci/file "test.clj"]
71+
(eval-string "
72+
(defn outer []
73+
(defn inner []
74+
(sci.impl/current-stacktrace))
75+
(inner))
76+
(outer)"))]
77+
(is (= [{:ns 'user, :name 'outer, :file "test.clj"}
78+
{:ns 'user, :name 'inner, :file "test.clj"}]
79+
stacktrace)))))
80+
6281
#_(deftest locals-test
6382
(testing "defn does not introduce fn-named local binding"
6483
(let [locals

0 commit comments

Comments
 (0)