Created
September 28, 2018 13:55
-
-
Save erdos/1e2f4b9d4fa551f6a4e55be0ddbf56e3 to your computer and use it in GitHub Desktop.
make all private vars visible for unit testing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(let [target (the-ns 'testable-namespace)] | |
(doseq [[k v] (ns-map target) | |
:when (and (var? v) (= target (.ns v)))] | |
(eval `(defn ~(symbol (str "-" k)) [~'& args#] (apply (deref ~v) args#))))) | |
;; Now if testable-namespace has a function valled fun1 | |
;; then i am able call -fun1 from the current namespace. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment