Skip to content

Commit

Permalink
Fix instrument for a dot special form case
Browse files Browse the repository at this point in the history
  • Loading branch information
pranav committed Mar 9, 2020
1 parent 1673e08 commit d10b4d2
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 3 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

* [#666](https://github.com/clojure-emacs/cider-nrepl/pull/666): Add a check in apropos var-query-map.
* [#669](https://github.com/clojure-emacs/cider-nrepl/pull/669): Fix NPE and add isDirectory check in slurp
* [#672](https://github.com/clojure-emacs/cider-nrepl/pull/672): Fix instrument for a dot special form case

### New Features

Expand Down
11 changes: 8 additions & 3 deletions src/cider/nrepl/middleware/util/instrument.clj
Original file line number Diff line number Diff line change
Expand Up @@ -73,15 +73,20 @@
'#{new} (cons (first args) (instrument-coll (rest args)))
'#{quote & var clojure.core/import*} args
'#{.} (list* (first args)
(second args)
(let [s (second args)]
(if (coll? s)
(->> (rest s)
instrument-coll
(concat (cons (first s) '())))
s))
(instrument-coll (rest (rest args))))
'#{def} (let [sym (first args)]
(list* (m/merge-meta sym
;; Instrument the metadata, because
;; that's where tests are stored.
(instrument (or (meta sym) {}))
(instrument (or (meta sym) {}))
;; to be used later for meta stripping
{::def-symbol true})
{::def-symbol true})
(map instrument (rest args))))
'#{set!} (list (first args)
(instrument (second args)))
Expand Down
8 changes: 8 additions & 0 deletions test/clj/cider/nrepl/middleware/util/instrument_test.clj
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,14 @@
'#{[(def foo "foo doc" (bp (bar) {:coor [3]} (bar))) []]
[(bar) [3]]})))

(deftest instrument-dot-test
(is (= (t/breakpoint-tester '(. clojure.lang.Numbers add 1 x))
'#{[(. clojure.lang.Numbers add 1 (bp x {:coor [4]} x)) []]
[x [4]]}))
(is (= (t/breakpoint-tester '(. clojure.lang.Numbers (add 1 x)))
'#{[x [2 2]]
[(. clojure.lang.Numbers (add 1 (bp x {:coor [2 2]} x))) []]})))

(deftest instrument-set!-test
(is (= (t/breakpoint-tester '(set! foo (bar)))
'#{[(set! foo (bp (bar) {:coor [2]} (bar))) []]
Expand Down

0 comments on commit d10b4d2

Please sign in to comment.