Fork me on GitHub
#cider
<
2023-03-13
>
andrea.crotti10:03:22

when I start both babashaka and lein repls in the same project it gets quite confused, and it tries to evaluate bb files in the clj repl and vice versa, is there any way to make that a bit smarter?

andrea.crotti10:03:47

in theory if I'm working on bb files it should always just use the bb repl right?

edipofederle16:03:19

Hello all, not sure if the right channel, but since it works when testing with Cider.. let me try here. I am using https://github.com/jgpc42/insn to generate Java Bytecode, I’m trying to have some tests like bellow. The thing is that it works fine when executing with cider-test-run-ns-tests but not when with lein test ( the (with-out-str (eval (. ~cname main)))` return empty string "" ) Any tip here? Thanks

(require '[insn.core :as insn])

(defn make [& {:as m}]
  (insn/new-instance m))

 (defn sum-bt [n]
   (make
    :name 'my.pkg.Test
    :methods [{:flags [:public :static], :name "main", :desc [:void]
               :emit [[:getstatic java.lang.System "out" java.io.PrintStream]
                      [:ldc2 n]
                      [:ldc2 n]
                      [:ladd]
                      [:invokevirtual java.io.PrintStream "println" [:long :void] false]
                      [:return]]}]))


(deftest sum-bt-test
  (let [cname 'my.pkg.Test
        _ (sum-bt 4)
        result (with-out-str (eval `(. ~cname main)))]
    (is (= result "8\n"))))