title: Threading arrow private defns in clojure.test
body: <p>Consider the following functions in an MVE (minimal viable example) namespace from a fresh <code>lein new app arrow-mve</code>. The function <code>extract-one</code> is public, and the function <code>extract-two</code> is private. I've included the <code>main-</code> function just for completeness and for the remote possibility that it's entailed in my problem:</p>
  
  <pre><code>(ns arrow-mve.core
    (:gen-class))
  
  (defn extract-one [m]
    (-&gt; m :a))
  
  (defn- extract-two [m]
    (-&gt; m :a))
  
  (defn -main
    "I don't do a whole lot ... yet."
    [&amp; args]
    (println "Hello, World!"))
  </code></pre>
  
  <p>In my parallel test namespace, I can test these functions as follows. I can test the public function <code>extract-one</code> either by a direct call or using the arrow-threading macro <code>-&gt;</code>. Also notice that I have no problem referring to the private function, <code>extract-two</code>, by its full <code>Var</code> in a direct call. These tests pass:</p>
  
  <pre><code>(ns arrow-mve.core-test
    (:require [clojure.test :refer :all]
              [arrow-mve.core :refer :all]))
  
  (deftest test-one-a
    (is (= 1 (extract-one {:a 1, :b 2}))))
  
  (deftest test-one-b
    (is (= 1 (-&gt; {:a 1, :b 2}
                 extract-one))))
  
  (deftest test-two-a
    (is (= 1 (#'arrow-mve.core/extract-two
              {:a 1, :b 2}))))
  </code></pre>
  
  <p>But I get a compile error when I attempt to call the private function <code>extract-two</code> with the arrow macro:</p>
  
  <pre><code>(deftest test-two-b
    (is (= 1 (-&gt; {:a 1, :b 2}
                 #'arrow-mve.core/extract-two))))
  
  $ lein test
  </code></pre>
  
  <blockquote>
  <pre><code>Exception in thread "main" java.lang.RuntimeException: Unable to resolve 
    var: arrow.mve.core/extract-two in this context, compiling:
  (arrow_mve/core_test.clj:10:12)
    at clojure.lang.Compiler.analyzeSeq(Compiler.java:6875)
    at clojure.lang.Compiler.analyze(Compiler.java:6669)
    at clojure.lang.Compiler.analyze(Compiler.java:6625)
  </code></pre>
  </blockquote>
  
  <p>Things get more strange when I make the test a little more complex. </p>
  
  <pre><code>(deftest test-two-b
    (is (= {:x 3.14, :y 2.72}
           (-&gt; {:a {:x 3.14, :y 2.72}, :b 2}
               #'arrow-mve.core/extract-two))))
  
  $ lein test
  </code></pre>
  
  <blockquote>
  <pre><code>Exception in thread "main" java.lang.ClassCastException: 
    clojure.lang.PersistentArrayMap cannot be cast to clojure.lang.Symbol, 
    compiling:(arrow_mve/core_test.clj:18:10)
  at clojure.lang.Compiler.analyzeSeq(Compiler.java:6875)
  at clojure.lang.Compiler.analyze(Compiler.java:6669)
  at clojure.lang.Compiler.analyzeSeq(Compiler.java:6856)
  </code></pre>
  </blockquote>
  
  <p>Again, the test passes in the direct-call form:</p>
  
  <pre><code>(deftest test-two-b
    (is (= {:x 3.14, :y 2.72}
           (#'arrow-mve.core/extract-two
            {:a {:x 3.14, :y 2.72}, :b 2}))))
  </code></pre>
  
  <p>I suspect that the problem is a limitation of macro-chaining through <code>deftest</code>, <code>is</code>, the reader macro <code>#'</code> for <code>Var</code>, and the arrow macro, and wondered if it was by design or a potential bug. Of course, in my real application (not this MVE), I have long and deep call chains that make using the arrow macros highly desirable. </p>