|
3 | 3 | [clojure.test :refer :all]
|
4 | 4 | [nrepl.server :as nrepl]
|
5 | 5 | [refactor-nrepl middleware
|
| 6 | + [analyzer :as analyzer] |
6 | 7 | [client :refer :all]
|
7 | 8 | [core :as core]]
|
8 | 9 | [clojure.string :as str])
|
|
58 | 59 | (defn ns-ast-throw-error-for-five [^String content]
|
59 | 60 | (if (.contains content "com.example.five")
|
60 | 61 | (throw (IllegalThreadStateException. "FAILED!"))
|
61 |
| - (#'refactor-nrepl.analyzer/cachable-ast content))) |
| 62 | + (#'analyzer/cachable-ast content))) |
62 | 63 |
|
63 | 64 | (deftest test-find-two-foo-errors-ignored
|
64 | 65 | (with-testproject-on-classpath
|
65 |
| - (with-redefs [refactor-nrepl.analyzer/ns-ast ns-ast-throw-error-for-five] |
| 66 | + (with-redefs [analyzer/ns-ast ns-ast-throw-error-for-five] |
66 | 67 | (let [transport (connect :port 7777)
|
67 | 68 | response (find-usages :transport transport :ns 'com.example.two
|
68 | 69 | :file (str test-project-dir "/src/com/example/one.clj")
|
|
186 | 187 | (with-testproject-on-classpath
|
187 | 188 | (let [five-file (str test-project-dir "/src/com/example/five.clj")
|
188 | 189 | transport (connect :port 7777)
|
189 |
| - response (find-usages :transport transport :name "foo" :file five-file :line 46 :column 10) |
| 190 | + response (find-usages :transport transport :name "foo" :file five-file :line 47 :column 10) |
190 | 191 | result (remove keyword? response)]
|
191 | 192 | (is (= 3 (count result)) (format "expected 3 results but got %d" (count result))))))
|
192 | 193 |
|
193 | 194 | (deftest find-local-in-optmap-default-linebreaks
|
194 | 195 | (with-testproject-on-classpath
|
195 | 196 | (let [five-file (str test-project-dir "/src/com/example/five.clj")
|
196 | 197 | transport (connect :port 7777)
|
197 |
| - response (find-usages :transport transport :name "foo" :file five-file :line 49 :column 12) |
| 198 | + response (find-usages :transport transport :name "foo" :file five-file :line 50 :column 12) |
198 | 199 | result (remove keyword? response)]
|
199 | 200 | (is (= 3 (count result)) (format "expected 3 results but got %d" (count result))))))
|
200 | 201 |
|
201 | 202 | (deftest find-local-in-optmap-default-in-let
|
202 | 203 | (with-testproject-on-classpath
|
203 | 204 | (let [five-file (str test-project-dir "/src/com/example/five.clj")
|
204 | 205 | transport (connect :port 7777)
|
205 |
| - response (find-usages :transport transport :name "foo" :file five-file :line 59 :column 12) |
| 206 | + response (find-usages :transport transport :name "foo" :file five-file :line 60 :column 12) |
206 | 207 | result (remove keyword? response)]
|
207 | 208 | (is (= 3 (count result)) (format "expected 3 results but got %d" (count result))))))
|
208 | 209 |
|
| 210 | +(core/with-clojure-version->= {:major 1 :minor 9} |
| 211 | + (deftest find-local-in-namespaced-destructuring |
| 212 | + (with-testproject-on-classpath |
| 213 | + (let [five-file (str test-project-dir "/src/com/example/five.clj") |
| 214 | + transport (connect :port 7777) |
| 215 | + response (find-usages :transport transport :name "foo" :file five-file :line 67 :column 16) |
| 216 | + result (remove keyword? response)] |
| 217 | + (is (= 2 (count result)) (format "expected 3 results but got %d" (count result))))))) |
| 218 | + |
209 | 219 | (deftest test-find-used-locals
|
210 | 220 | (with-testproject-on-classpath
|
211 | 221 | (let [five-file (str test-project-dir "/src/com/example/five.clj")
|
212 | 222 | transport (connect :port 7777)]
|
213 |
| - (is (= (find-unbound :transport transport :file five-file :line 12 :column 6) |
| 223 | + (is (= (find-unbound :transport transport :file five-file :line 13 :column 6) |
214 | 224 | '(s)))
|
215 |
| - (is (= (find-unbound :transport transport :file five-file :line 13 :column 13) |
| 225 | + (is (= (find-unbound :transport transport :file five-file :line 14 :column 13) |
216 | 226 | '(s sep)))
|
217 | 227 |
|
218 |
| - (is (= (find-unbound :transport transport :file five-file :line 20 :column 16) |
| 228 | + (is (= (find-unbound :transport transport :file five-file :line 21 :column 16) |
219 | 229 | '(p)))
|
220 |
| - (is (= (find-unbound :transport transport :file five-file :line 27 :column 8) |
| 230 | + (is (= (find-unbound :transport transport :file five-file :line 28 :column 8) |
221 | 231 | '(sep strings)))
|
222 | 232 |
|
223 |
| - (is (= (find-unbound :transport transport :file five-file :line 34 :column 8) |
| 233 | + (is (= (find-unbound :transport transport :file five-file :line 35 :column 8) |
224 | 234 | '(name)))
|
225 | 235 |
|
226 |
| - (is (= (find-unbound :transport transport :file five-file :line 37 :column 5) |
| 236 | + (is (= (find-unbound :transport transport :file five-file :line 38 :column 5) |
227 | 237 | '(n)))
|
228 |
| - (is (= (find-unbound :transport transport :file five-file :line 41 :column 4) |
| 238 | + (is (= (find-unbound :transport transport :file five-file :line 42 :column 4) |
229 | 239 | '(x y z a b c))))))
|
230 | 240 |
|
231 | 241 | (deftest find-unbound-fails-on-cljs
|
|
0 commit comments