diff --git a/src/duct/repl/refers.clj b/src/duct/repl/refers.clj index 30ad190..d80cb90 100644 --- a/src/duct/repl/refers.clj +++ b/src/duct/repl/refers.clj @@ -9,13 +9,17 @@ (require ns-sym) (if (= alias name-sym) (refer ns-sym :only [name-sym]) - (refer ns-sym :only [name-sym] :rename {name-sym alias})))))) + (refer ns-sym :only [name-sym] :rename {name-sym alias}))))) + (when-some [syms (seq (keys refers))] + (prn (keyword (str ns-sym) "added") syms))) (defn- remove-refers [ns-sym refers] (let [ns (find-ns ns-sym)] (doseq [[alias sym] refers] (when (identical? (resolve sym) (ns-resolve ns alias)) - (ns-unmap ns alias))))) + (ns-unmap ns alias)))) + (when-some [syms (seq (keys refers))] + (prn (keyword (str ns-sym) "removed") syms))) (defn- identical-kvs [m1 m2] (reduce-kv (fn [m k v] (if (= v (m2 k ::miss)) (assoc m k v) m)) diff --git a/test/duct/repl/refers_test.clj b/test/duct/repl/refers_test.clj index e2b693d..e697f59 100644 --- a/test/duct/repl/refers_test.clj +++ b/test/duct/repl/refers_test.clj @@ -32,3 +32,12 @@ (is (= {'ret-one `return-one} refers')) (is (= 1 ((ns-resolve ns 'ret-one)))) (is (nil? (ns-resolve ns 'return-two)))))) + +(deftest test-prn-output + (is (= (str ":user/added (ret-one return-two)\n" + ":user/removed (ret-one return-two)\n") + (with-out-str + (let [refers (ig/init-key :duct.repl/refers + {'ret-one `return-one + 'return-two `return-two})] + (ig/halt-key! :duct.repl/refers refers))))))