Fork me on GitHub
#babashka
<
2020-01-30
>
sogaiu00:01:07

here's what i got for that:

$ ./bb 
Babashka v0.0.67 REPL.
Use :repl/quit or :repl/exit to quit the REPL.
Clojure rocks, Bash reaches.

user=> (require '[clojure.test :refer [is deftest] :as t])
nil
user=> (defmethod t/assert-expr 'roughly [msg form]
  `(let [op1# ~(nth form 1)
         op2# ~(nth form 2)
         tolerance# (if (= 4 ~(count form)) ~(last form) 2)
         decimals# (/ 1. (Math/pow 10 tolerance#))
         result# (< (Math/abs (- op1# op2#)) decimals#)]
     (t/do-report 
       {:type (if result# :pass :fail)
        :message ~msg
        :expected (format "%s should be roughly %s with %s tolerance" 
                          op1# op2# decimals#)
        :actual result#})
     result#))
#object[clojure.lang.MultiFn 0x61a22b2d "clojure.lang.MultiFn@5573e76be080"]
user=> (deftest PI-test
  (is (roughly 3.14 Math/PI 2))
  (is (roughly 3.14 Math/PI 3)))
#'user/PI-test
user=> (t/test-var #'PI-test)

FAIL in (PI-test) (test.clj:370)
expected: "3.14 should be roughly 3.141592653589793 with 0.001 tolerance"
  actual: false
nil

borkdude07:01:53

That seems correct

🙂 4
borkdude09:01:30

with 0.0.67 bundling clojure.test, spartan.test is now deprecated: https://github.com/borkdude/spartan.test/blob/master/README.md

mauricio.szabo14:01:01

Are there plans to implement ns-map, ns-aliases and ns-publics on bb?

mauricio.szabo14:01:33

This could allow a simple autocomplete to work 😁

borkdude14:01:20

@mauricio.szabo ns-aliases and ns-publics and ns-interns should work now

borkdude14:01:57

ns-map isn't there apparently, but I'll make an issue