This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2017-12-06
Channels
- # adventofcode (181)
- # aws (6)
- # beginners (112)
- # boot (38)
- # cider (11)
- # cljs-dev (12)
- # cljsrn (2)
- # clojure (187)
- # clojure-greece (31)
- # clojure-italy (19)
- # clojure-new-zealand (1)
- # clojure-poland (1)
- # clojure-spec (20)
- # clojure-uk (114)
- # clojurescript (97)
- # core-logic (25)
- # cursive (3)
- # data-science (17)
- # datascript (3)
- # datomic (23)
- # defnpodcast (1)
- # duct (5)
- # emacs (3)
- # fulcro (299)
- # graphql (108)
- # jobs (1)
- # juxt (4)
- # lein-figwheel (7)
- # leiningen (1)
- # lumo (9)
- # nrepl (2)
- # off-topic (10)
- # om (2)
- # onyx (36)
- # pedestal (1)
- # perun (3)
- # re-frame (14)
- # reagent (12)
- # ring (2)
- # rum (11)
- # shadow-cljs (6)
- # spacemacs (4)
- # unrepl (8)
Hey all: I'd like make some spec assertions regardless of whether check-asserts
has been set. It's important these assertions are always made. To that end I'm looking to use assert*
. It's part of the public api, but the doc-string says Do not call this directly, use 'assert'.
. Is there something important that I need to know? Seems like it fits the bill otherwise.
Could you do something like (asset (s/valid? xxx))
or (binding [s/*assert-flag-thing* true] (s/assert ::x 1))
.
you can use assert*
but it’s api is subject to change as part of the implementation - it’s public because it needs to be accessible by the macro when expanded
I'm a complete beginner in clojure-spec, my question is, why don't I get spec error here?
(s/def ::spec1 string?)
(defn silly []
1)
(s/fdef silly
:ret string?
:fn string?)
(silly)
if you’re looking to assert that calls to silly
have valid inputs, you can use instrument
. Although that’s not going to care about your :ret
or :fn
function specs
I thought that was done with :args within fdef? I was hoping it would tell me that the number 1 is not string
ah ok! thanks, I'm reading trough the manual and therefore had this question, I'll continue to read further.
oh, if you’re only concerned about the return value of your function, instrument
isn’t going to assert on that. You can use check
for that though.
yes that's what I was looking for, but in real world cases I'd see spec being most helpful in the args.
@U053S2W0V how is it different from cljs.spec.test.alpha/instrument
that said, that's exacly the reason why I want to use spec, to get these errors right away.