This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2017-12-14
Channels
- # adventofcode (62)
- # beginners (78)
- # boot (26)
- # boot-dev (9)
- # cider (73)
- # cljs-dev (33)
- # cljsrn (36)
- # clojure (159)
- # clojure-android (1)
- # clojure-austin (1)
- # clojure-greece (79)
- # clojure-italy (10)
- # clojure-nl (3)
- # clojure-russia (11)
- # clojure-spec (33)
- # clojure-uk (26)
- # clojurescript (107)
- # core-async (22)
- # core-logic (12)
- # cursive (16)
- # datomic (13)
- # devcards (5)
- # duct (36)
- # emacs (4)
- # figwheel (3)
- # fulcro (107)
- # graphql (171)
- # hoplon (27)
- # instaparse (24)
- # jobs-discuss (34)
- # juxt (3)
- # lein-figwheel (1)
- # leiningen (8)
- # lumo (11)
- # off-topic (9)
- # onyx (79)
- # parinfer (1)
- # pedestal (75)
- # re-frame (27)
- # rum (1)
- # shadow-cljs (11)
- # spacemacs (20)
- # specter (17)
- # unrepl (96)
@johanatan seems to work fine
> (s/exercise-fn `subtract)
> ([[2 1] 1] [[7 1] 6] [[3 1] 2] [[4 3] 1] [[13 4] 9] [[5 4] 1] [[7 3] 4] [[17 1] 16] [[96 3] 93] [[14 3] 11])
> (stest/check `subtract)
> ({:spec #object[clojure.spec.alpha$fspec_impl$reify__2451 0x2bfc33f4 "clojure.spec.alpha$fspec_impl$reify__2451@2bfc33f4"], :clojure.spec.test.check/ret {:result true, :num-tests 1000, :seed 1513263691452}, :sym practice.specs/subtract})
is there a reason you need the args vector to conform to a map?
if you supply a generator for ::args-tup, you shouldn't have to worry about failure during generative testing
easy generator for a strictly descending pair of numbers: (gen/let [[a b] (gen/tuple gen/large-integer gen/large-integer)] (let [[a b] (sort [a b])] [(inc a) b]))
I was looking at updating the Clojure cheat sheet for v1.9, now that it is out. I was wondering -- is there a list somewhere of all Clojure predicates for which test.check has generators included, vs. those it does not have generators for?
I expect there's a data structure in the spec code mapping specs to generators
If someone beats me to finding a link to that, let me know. I may want to link to it.
if you have a list of predicates, then programmatically figuring out which have generators should be easy
Is there some small expression you can evaluate in a REPL to determine if a predicate has a generator already?
I thought there was a function in the spec API that takes a spec and returns a generator
There are some things in gen namespace too
And that’s where the built in mapping is set
gen/gen-for-pred
Thanks, s/gen is very helpful. And dang, I could have really added a lot of value by helping with the generator for zero? 🙂
I couldn't have been very helpful, of course. Simply my way of expressing surprise that there was such a generator.
(gen/one-of (gen/elements [(float 0) (int 0) 0.0 0 0N (biginteger 0) -0.0]) (gen/let [scale (gen/large-integer* {:min Integer/MIN_VALUE :max Integer/MAX_VALUE})] (.setScale 0M scale)))
I assume?
Yes, the most complex part about it is if you want to generate every value that can satisfy zero?
I probably should have made my snide remark about the predicate nil? instead, since it would be more obvious.
I am probably having a senior moment here on my memory -- is there any reasonably common term for any type that isn't a collection?
It is, and I am understanding more every day what memory lapses feel like 🙂
I increasingly find myself forgetting what I’m about to do as I walk across my tiny apartment to do it
tattoos are the answer put "things that aren't collections are scalars" on your left arm
On a related note, I watched the movie "Memento" for the first time recently. Sound advice.
more likely he will soon watch it for the last time
It felt like the first time, anyway
If only I can keep forgetting my favorite movies and books, I can get full enjoyment from them multiple times -- if I can remember which ones they are.
@U3DAE8HMG LOLAHTEMLTMW
(Laugh Out Loud And Had To Explain My Laughter To My Wife)