From afb4a9c0a3707eda6b142cd25120bb2835425c2b Mon Sep 17 00:00:00 2001 From: vemv Date: Sun, 29 Aug 2021 16:37:54 +0200 Subject: [PATCH] Add `refactor-nrepl.find-symbol-test` Tries reproducing https://github.com/clojure-emacs/clj-refactor.el/issues/485 `find-symbol` seemed to lack test coverage anyway. --- test/refactor_nrepl/find_symbol_test.clj | 23 +++++++++++++++++++++ testproject/src/com/move/ns_to_be_moved.clj | 3 +++ 2 files changed, 26 insertions(+) create mode 100644 test/refactor_nrepl/find_symbol_test.clj diff --git a/test/refactor_nrepl/find_symbol_test.clj b/test/refactor_nrepl/find_symbol_test.clj new file mode 100644 index 00000000..3cf4786a --- /dev/null +++ b/test/refactor_nrepl/find_symbol_test.clj @@ -0,0 +1,23 @@ +(ns refactor-nrepl.find-symbol-test + (:require + [clojure.test :refer [deftest is]] + [refactor-nrepl.unreadable-files :refer [ignore-errors-str]] + [refactor-nrepl.find.find-symbol :as sut]) + (:import + (java.io File))) + +(def from-file-path + (-> "testproject/src/com/move/ns_to_be_moved.clj" File. .getAbsolutePath)) + +(deftest works + (let [found (sut/find-symbol {:file from-file-path + :ns "com.move.ns-to-be-moved" + :line 11 + :column 7 + :name "fn-to-be-moved" + :ignore-errors ignore-errors-str + :dir "testproject/src"})] + (is (seq found) + (pr-str found)) + (is (= 4 (->> found (map :file) distinct count)) + "Finds different files with references to the queried symbol"))) diff --git a/testproject/src/com/move/ns_to_be_moved.clj b/testproject/src/com/move/ns_to_be_moved.clj index 06c32b61..d7036f25 100644 --- a/testproject/src/com/move/ns_to_be_moved.clj +++ b/testproject/src/com/move/ns_to_be_moved.clj @@ -1,5 +1,8 @@ (ns com.move.ns-to-be-moved) +;; Tries reproducing https://github.com/clojure-emacs/clj-refactor.el/issues/485 +(set! *warn-on-reflection* true) + (def var-to-be-moved) (def ^:private private-var-to-be-moved)