Fork me on GitHub
#testify
<
2024-04-28
stefanvstein18:04:33

Hello @genekim Sorry for being quiet. I guess previous week was a bit too stressful for me. Now I'm currently unable to reproduce the problem with not seeing test-comment. I think I was tripped by myself, fiddling a bit too much in the repl, when I lost reference to test-comment. I also thought that the eval-as-use was broken, but I was probably just too occupied with other things.. And wrote something as following, without thinking clearly:

(ns my.namespace
  (:require [testify :refer [test-comment eval-as-use]]))

(def a 23)

(test-comment
  (def a 12)
  (println a))

(comment
  (eval-as-use 'my.namespace))
..and got devastated when I saw the error message:
Syntax error (IllegalStateException) compiling def at (src/my/namespace.clj:8:3).
a already refers to: #'my.namespace/a in namespace: my.namespace-16699
But that is how it should be. The content of the test-comment is evaluated in a new namespace, here my.namespace-16699, which is referring to my.namespace with use. You see that process on out. If you refer everything in a namespace, here 'a, and try to add something equally named, here (def a 12), you should get an error, and you do get that same error doing the same thing in a repl manually. So nothing wrong there. Now, I guess it's time to see if I can try to reproduce your experience, in an environment similar to yours. Eager to find new issues... Thanks again

stefanvstein19:04:41

@genekim. Now I have tried Cursive for the first time in many years. I don't really remember the last time, so I can't say whether its an improvement. But I sure it is, as it was pretty easy. I wrote the following in a clojure project:

(ns testingsomerepl.core
  (:require [testify :refer [test-comment eval-in-ns]]))

(test-comment
  (println "Hello"))

(comment
  (eval-in-ns 'testingsomerepl.core))
I managed to start a repl, found a way to eval content of the comment, and it did write the following in the repl window:
(eval-in-ns 'testingsomerepl.core)
(clojure.core/in-ns 'testingsomerepl.core)
=> #object[clojure.lang.Namespace 0x681035ac "testingsomerepl.core"]

(println "Hello")
Hello
=> nil

=> nil
.. success and perhaps a moment to consider moving away from emacs 🙂 Does the similar thing work for you?