This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2019-03-31
Channels
- # announcements (16)
- # beginners (52)
- # calva (44)
- # cider (82)
- # clojure (21)
- # clojure-greece (1)
- # clojure-losangeles (1)
- # clojure-spec (8)
- # clojure-uk (3)
- # clojurescript (55)
- # community-development (26)
- # cursive (18)
- # datomic (7)
- # editors (6)
- # events (1)
- # fulcro (19)
- # kaocha (1)
- # klipse (1)
- # off-topic (13)
- # re-frame (1)
- # ring-swagger (2)
- # spacemacs (2)
- # vim (15)
Announcing the intial release of defn-spec, a library to create specs inline with your defn
. It uses the same syntax as Schema, so you probably already know how to use it. https://danielcompton.net/2019/03/31/announcing-defn-spec
https://github.com/danielcompton/defn-spec
About attrs maps in functions. I use them pretty often. Mostly for pre and post predicates (which I guess is less important with this library), but also for inlining tests.
@U0ETXRFEW interesting! How do you run those inline tests?
Same way as I run any tests. The Clojure test runner looks there for them. Unfortunately the ClojureScript test runner does not. I tried to fix that a while ago, but my macro fu was insufficient.
Like so:
(defn absolute
"The absolute value of a number."
{:test (fn []
(is= (abs 5) 5)
(is= (abs -2) 2)
(is= (abs 0) 0))}
[x]
{:pre [(number? x)]}
(if (pos? x)
x
(- x)))
I can recommend giving inline tests a try. I sometimes fall into a very sweet flow of doing my REPL experiments inside that attrs-map, where some of the experiments will stay as tests.
@U0ETXRFEW the attr maps that don't work are ones that you put at the end of your function definition after all of the arities
Looking at the definition (defn name doc-string? attr-map? ([params*] prepost-map? body) + attr-map?)
it's the last attr-map?
which isn't supported
Wow! Here I was thinking Elixir’s doc-string tests were really clever, Clojure accomplished the same thing except even more simple — it’s just a map with regular Clojure instead of a specially formatted string.
I just releases the v0.3.0 of https://github.com/hiposfer/rata. A library to help manage state on Clojurescript app with Datascript and Reagent 🙂. Your feeback is most welcome