Skip to content

Commit 40f1aac

Browse files
committed
Add/update tests for new #break semantics
1 parent aaac6a9 commit 40f1aac

File tree

1 file changed

+44
-3
lines changed

1 file changed

+44
-3
lines changed

test/clj/cider/nrepl/middleware/debug_integration_test.clj

+44-3
Original file line numberDiff line numberDiff line change
@@ -136,18 +136,59 @@
136136
(f)))))
137137

138138
(deftest debug-expression-test
139+
(--> :eval "(ns user.test.debug)")
140+
(<-- {:ns "user.test.debug"})
141+
(<-- {:status ["done"]})
142+
139143
(testing "normal eval (no debugging)"
140144
(--> :eval "(+ 2 3)")
141145
(<-- {:value "5"})
142146
(<-- {:status ["done"]}))
143147

144-
(testing "#break reader, no breakpoints"
145-
;; This code has only literals and core functions, so it should
146-
;; not break, but should just return the value
148+
(testing "Top level breakpoints do not trigger"
149+
;; Since triggering a breakpoint to inspect the toplevel value is no different
150+
;; from returning the value.
147151
(--> :eval "#break (+ 2 3)")
148152
(<-- {:value "5"})
149153
(<-- {:status ["done"]}))
150154

155+
(testing "#break on return value of call"
156+
(--> :eval "(do #break (+ 2 3) :ok)")
157+
(<-- {:debug-value "5"})
158+
(--> :next)
159+
(<-- {:value ":ok"})
160+
(<-- {:status ["done"]}))
161+
162+
(testing "#dbg reader on uninteresting forms"
163+
;; The return value of a def form is uninteresting, as well as the sub forms
164+
;; which are just core vars and literals.
165+
;; #dbg should not break on any of them and just return the value.
166+
(--> :eval "(do #dbg (def foo [2 + {:skip \"me\"}]) foo)")
167+
(<-- {:value "[2 #function[clojure.core/+] {:skip \"me\"}]"})
168+
(<-- {:status ["done"]}))
169+
170+
(testing "#break reader on uninteresting forms"
171+
;; #break signifies that the user explicitly wants to set a breakpoint there,
172+
;; so ignore any of #dbg reader's heuristics on what an interesting form is.
173+
(--> :eval "(let [a 1] #break [2 3], #break {:a a}, #break + #break (def foo 4) foo) ")
174+
(<-- {:debug-value "[2 3]"})
175+
(--> :next)
176+
(<-- {:debug-value "{:a 1}"})
177+
(--> :next)
178+
(<-- {:debug-value "#function[clojure.core/+]"})
179+
(--> :next)
180+
(<-- {:debug-value "#'user.test.debug/foo"})
181+
(--> :next)
182+
(<-- {:value "4"})
183+
(<-- {:status ["done"]}))
184+
185+
(testing "#break reader on literals"
186+
;; The instrumenter cannot tag literals which don't support metadata,
187+
;; so #break does not work on them.
188+
(--> :eval "(do #break :kwd, #break 123, #break \"string\" :ok)")
189+
(<-- {:value ":ok"})
190+
(<-- {:status ["done"]}))
191+
151192
(testing "#dbg reader, with breaks"
152193
(--> :eval
153194
"#dbg

0 commit comments

Comments
 (0)