This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2016-07-28
Channels
- # admin-announcements (4)
- # beginners (11)
- # boot (148)
- # cider (74)
- # cljs-dev (31)
- # cljsrn (30)
- # clojure (55)
- # clojure-berlin (15)
- # clojure-greece (1)
- # clojure-japan (18)
- # clojure-poland (35)
- # clojure-russia (72)
- # clojure-spec (35)
- # clojure-uk (34)
- # clojurescript (134)
- # cursive (26)
- # datomic (42)
- # dirac (7)
- # editors-rus (1)
- # emacs (17)
- # hoplon (29)
- # jobs-rus (3)
- # juxt (1)
- # luminus (11)
- # off-topic (9)
- # om (66)
- # onyx (49)
- # pedestal (1)
- # perun (19)
- # proton (13)
- # protorepl (5)
- # re-frame (31)
- # reagent (13)
- # ring (2)
- # spacemacs (1)
- # specter (40)
- # spirituality-ethics (2)
- # test-check (41)
- # untangled (7)
- # yada (17)
@gfredericks: chuck.gen/string-from-regex is nothing short of magic, impressive
Check out s/int-in or s/double-in
small attempt at specing the latest ring specification -> https://github.com/mpenet/ring-spec/blob/master/src/clj/qbits/ring_spec.clj
hi! if i have (s/def ::decimal #(instance? BigDecimal %)) how to make (s/exercise ::decimal) working? I suppose a should create custom generator in spec, but can't find how to do it. thanx
(s/def :decimal (s/spec #(...) :gen (constantly (gen/fmap #(BigDecimal. %) gen/nat)))) (untested)
@mike1452: super handy cheat-cheat -> https://github.com/clojure/test.check/blob/master/doc/cheatsheet.md
@mpenet: 😞 doesn't work. I've tried similar ways and unfortunately can't get result. i'm dumb :((
(s/def ::decimal (s/spec #(instance? BigDecimal %)
:gen (constantly (gen/fmap #(BigDecimal. %) gen/nat))))
exercise returns -> ([0M 0M] [0M 0M] [1M 1M] [2M 2M] [1M 1M] [0M 0M] [4M 4M] [1M 1M] [2M 2M] [5M 5M])
thanx. can you show your gen namespace from require section?
Maybe it's a good time to get a good bigdec and bigint and ratio generator in test.check
have trioubles with gen namespace
Alias gen already exists in namespace arina-aaa.atomix.spec, aliasing clojure.spec.gen
(:require [clojure.spec :as s] [clojure.test.check.generators :as gen])
Ah! REPL restart helps!
thanx!
Oh right. I meant a good ratio generator :)
I'm a little caught up on s/def
being a macro. Is it possible to do something like:
(let [x :my/spec-name]
(s/def x string?))
The problem seems to be that def
expands, and the first argument retains the value of the symbol x, not the value that it refers to (`:my/spec-name`)
you can do it with another macro:
(let [x :user/the-x]
`(s/def ~x string?))
;;=> (clojure.spec/def :user/the-x clojure.core/string?)
thanks @alexmiller. that looks better indeed