This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2017-07-06
Channels
- # beginners (90)
- # boot (83)
- # cider (39)
- # clara (4)
- # cljs-dev (124)
- # cljsrn (10)
- # clojure (208)
- # clojure-boston (1)
- # clojure-italy (13)
- # clojure-nlp (3)
- # clojure-russia (34)
- # clojure-spec (63)
- # clojure-uk (101)
- # clojurescript (65)
- # community-development (13)
- # copenhagen-clojurians (1)
- # core-async (1)
- # cursive (24)
- # datascript (1)
- # datomic (65)
- # emacs (20)
- # graphql (20)
- # hoplon (21)
- # instaparse (18)
- # jobs (5)
- # jobs-discuss (2)
- # leiningen (8)
- # luminus (32)
- # midje (1)
- # mount (3)
- # off-topic (18)
- # om (10)
- # parinfer (6)
- # pedestal (2)
- # planck (2)
- # precept (22)
- # protorepl (7)
- # re-frame (45)
- # reagent (9)
- # ring (1)
- # ring-swagger (4)
- # rum (2)
- # spacemacs (5)
- # sql (2)
- # unrepl (13)
- # untangled (8)
- # yada (5)
let
in particular is a macro, and the only macro of the test.check generators
and it looks like the patch doesn't lazy-load it, it completely reimplements it, with different behavior
I'm not sure if lazy-loading a macro is even possible
hi guys, is there any good way to test all fdef in my project instead of using clojure.spec.test.alpha/check
for each one explicitly.
@nxqd: guessing you mean fdef
not fspec
but if you call check
with 0-args it should run all var specs that have been loaded
no idea - guessing not
stest/check
does parallelize generative tests using pmap
https://github.com/clojure/spec.alpha/blob/8f4e6f7d53db30b20d1f7b1c190f21f40d12ca49/src/main/clojure/clojure/spec/test/alpha.clj#L410-L411
@U06A9614K thanks for your info ( And sorry for my lazy ass ... )
Hmmm… wondering if generator errors like ExceptionInfo Couldn't satisfy such-that predicate after 100 tries. clojure.core/ex-info (core.clj:4725)
would be better if they told you which generator/spec failed to generate a value. The stack trace doesn’t seem to contain many useful clues.
Would be nice if the ex-info
data contained something like {:generator #function[foo.bar/bar-gen] :spec :foo.bar/valid-bar?}
rickmoynihan: test.check didn't provide a mechanism for this until 0.10.0-alpha1
; now that that's released, clojure.spec can be modified to make use of it
Cool!
One thing I’m not quite clear on is the precise relationship between clojure.spec
and test.check
. I obviously understand spec uses it, and wraps it via the lazy-load mechanism. But is spec promising to expose everything inside test.check (plus its own stuff), or is it deciding on what to expose/not-expose? If so how are those decisions being made?
the exposing-vs-not distinction isn't very impactful since you can reference test.check generators directly in your spec usage; I don't think that was ever disintended
I don't know about why some generators don't have proxy versions in spec (other than let
)
Yeah, I’ve been thinking I might be better just using test.check.generators rather than specs lazy loaded ones… What would the disadvantage be of doing that? Presumably I’d have to make sure the non-lazy-loaded generators were only ever included in dev envs?
It really frustrates me that the lazy loaded ones don’t have docstrings.
"have to" is strong, depends on how much you care about your production deps
that sounds fixable
> depends on how much you care about your production deps Yeah, I guess I don’t when its an app. A library should probably be more conservative though.
oh definitely, yes
but yeah, you could stick the generators in /test
or /dev
or something, and then have your own sort of lazy loading thing if you need to reference them from /src
its a shame about let
not being included. It feels much nicer than fmap
and others.
but understand the macroness of it complicates it
yeah;
I suppose you could have a weird thing where the macro tries to require test.check
and if it fails it expands to exception-throwing code
That seems like a nice idea
As an aside are you involved at all in the development of clojure.spec
beyond your work on test.check
?
not beyond the details of the integration
Thanks for explaining, and all your work on test.check. btw, I updated the CLJ-1989 with your comments on let. Hope you don’t mind, and that they accurately reflect your opinion: https://dev.clojure.org/jira/browse/CLJ-1989?focusedCommentId=46211#comment-46211
only nitpick is that the macro wouldn't expand to a require call, it would actually call require
before constructing any expanded code
e.g.,
(defmacro let [& args] (try (require ...) `(...) (catch Exception e `(throw ...))))
yeah fair point, that’s what I meant… will update the ticket
Hmm also just noticed a small problem with check
which is that you can’t both run it on all fdefs and provide custom options
ahh its ok checkable-syms
is exposed so can do it by hand
@gfredericks: Do you know if test.check 0.10.0-alpha2
is compatible with the latest clj 1.9 / spec?
@rickmoynihan should be, yeah
awesome
@peeja I'm not sure what you asked, but I think you might want to check (s/with-gen)
then you can set any generator you want to your spec, no mater the predicate
Right, I mean I want to register that as the generator to use everywhere (if it's not overridden)
I'm missing something about combining s/and and s/or:
`
(s/def ::identifier (s/and (s/or :keyword simple-keyword?
:symbol simple-symbol?)
graphql-identifier?))
@peeja what you can do is define a spec, and then re-use that spec instead, eg:
(s/def ::my-spec (s/with-gen my-pred? #(gen-fn)))
(s/def ::other-spec ::my-spec)
(s/def ::another-one (s/and ::my-spec other?))
then it will inherit the generator
@hlship on the and
case, the next predicate will receive the conformed version from the previous one
(s/explain ::identifier :foo)
java.lang.ClassCastException: clojure.lang.MapEntry cannot be cast to clojure.lang.Named
`
I'm guessing that the entire map conformed by
s/or
(e.g., {:keyword :foo}
) is being passed to graphql-identifier?
(which expects a String, Keyword, or Symbol).
So, what's the correct way to deal with this situation? I'd rather not do the identifier check first. I guess I could change graphql-identifier?
to expect the conformed result from the s/or
?
so, your graphql-identifier?
will receive something like {:keyword :bla}
or {:symbol some-sym}
@wilkerlucio Yeah, that makes sense. I was hoping to do it straight on the predicate because it looks like a nicer API, but if that's not how it's meant to work, then that works.
@peeja if you look at the sources for the spec generators, it uses a map to convert from symbol -> generator
, I guess we can suggest this to be replaced with a multi-method
making it extensible from the outside