Finding vars from dynamically created namespaces in clojure

Posted by Tom Crayford on Stack Overflow See other posts from Stack Overflow or by Tom Crayford
Published on 2010-05-21T00:26:26Z Indexed on 2010/05/21 0:30 UTC
Read the original article Hit count: 175

Filed under:

The following test fails:

(ns clojure_refactoring.rename-fn-test
  (:use clojure.test))

(deftest test-fn-location
  (in-ns 'refactoring-test-fn-rename)
  (clojure.core/refer-clojure)
  (defn a [b] (inc b))
  (in-ns 'clojure_refactoring.rename-fn-test)
  (is (not= (find-var 'refactoring-test-fn-rename/a)
        nil))
  (remove-ns 'refactoring-test-fn-rename))

That is, find-var (of a var I've just created, in a namespace I've just create) returns nil. This behaviour doesn't happen at the repl, where typing out the steps of the test works just fine.

Am I doing something wrong, or is this just something that doesn't work in clojure right now?

© Stack Overflow or respective owner

Related posts about clojure