rcf
rcf copied to clipboard
(tests) should not return the final assertion, it's annoying
This is what I see for a passing test:

(tests
(unqualify ::x) := :x
(unqualify nil) := nil
(unqualify "") :throws AssertionError
)
✅✅✅=>
#error{:cause "Assert failed: (or (nil? ?qualified-kw) (qualified-keyword? ?qualified-kw))",
:via [{:type java.lang.AssertionError,
:message "Assert failed: (or (nil? ?qualified-kw) (qualified-keyword? ?qualified-kw))",
:at [contrib.data$unqualify invokeStatic "data.cljc" 21]}],
:trace [[contrib.data$unqualify invokeStatic "data.cljc" 21]
[contrib.data$unqualify invoke "data.cljc" 21]
[contrib.data$eval44265 invokeStatic "data.cljc" 30]
[contrib.data$eval44265 invoke "data.cljc" 30]
[clojure.lang.Compiler eval "Compiler.java" 7194]
[clojure.lang.Compiler eval "Compiler.java" 7149]
[clojure.core$eval invokeStatic "core.clj" 3215]
[clojure.core$eval invoke "core.clj" 3211]
[nrepl.middleware.interruptible_eval$evaluate$fn__1013$fn__1014
invoke
"interruptible_eval.clj"
87]
[clojure.lang.AFn applyToHelper "AFn.java" 152]
[clojure.lang.AFn applyTo "AFn.java" 144]
[clojure.core$apply invokeStatic "core.clj" 667]
[clojure.core$with_bindings_STAR_ invokeStatic "core.clj" 1990]
[clojure.core$with_bindings_STAR_ doInvoke "core.clj" 1990]
[clojure.lang.RestFn invoke "RestFn.java" 425]
[nrepl.middleware.interruptible_eval$evaluate$fn__1013
invoke
"interruptible_eval.clj"
87]
[clojure.main$repl$read_eval_print__9206$fn__9209 invoke "main.clj" 437]
[clojure.main$repl$read_eval_print__9206 invoke "main.clj" 437]
[clojure.main$repl$fn__9215 invoke "main.clj" 458]
[clojure.main$repl invokeStatic "main.clj" 458]
[clojure.main$repl doInvoke "main.clj" 368]
[clojure.lang.RestFn invoke "RestFn.java" 1523]
[nrepl.middleware.interruptible_eval$evaluate
invokeStatic
"interruptible_eval.clj"
84]
[nrepl.middleware.interruptible_eval$evaluate invoke "interruptible_eval.clj" 56]
[nrepl.middleware.interruptible_eval$interruptible_eval$fn__1044$fn__1048
invoke
"interruptible_eval.clj"
152]
[clojure.lang.AFn run "AFn.java" 22]
[nrepl.middleware.session$session_exec$main_loop__1112$fn__1116
invoke
"session.clj"
202]
[nrepl.middleware.session$session_exec$main_loop__1112 invoke "session.clj" 201]
[clojure.lang.AFn run "AFn.java" 22]
[java.lang.Thread run "Thread.java" 833]]}
tests returns the last value, as in do. Should errors be handled differently because of the way they are printed at the REPL?
In my current opinion tests should discard the last value and return nil, in practice I do not recall ever getting value from this and only being annoyed when the REPL prints a long value. (needing to interrupt flow and touch the mouse to find out if the test passed)
here is another example in datafy-fs:
(tests
; careful, calling seq loses metas on the underlying
(def h (clojure.java.io/file "src/"))
(type h) := java.io.File
"(datafy file) returns an EDN-ready data view that is one layer deep"
(datafy h)
:= #:user.datafy-fs{:name "src",
:absolute-path _,
:size _,
:modified _,
:created _,
:accessed _,
:kind ::dir,
:children _
:parent ...})
and the REPL output looks like:

this is what i want to see, 100% of the time:

It also makes the nextjournal notebook experiments a bit worse - https://nextjournal.com/dustingetz/datafynav-implementations-for-javaiofile – I see these notebooks as essays or docs and I want to carefully direct the user's attention by removing unnecessary noise
duplicate https://github.com/hyperfiddle/rcf/issues/61