This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2017-01-28
Channels
- # aws (1)
- # aws-lambda (1)
- # beginners (19)
- # boot (7)
- # cider (9)
- # cljs-dev (311)
- # cljsjs (34)
- # cljsrn (8)
- # clojars (7)
- # clojure (41)
- # clojure-argentina (3)
- # clojure-russia (15)
- # clojure-spec (15)
- # clojure-uk (11)
- # clojurescript (83)
- # datomic (45)
- # emacs (7)
- # hoplon (13)
- # klipse (2)
- # lein-figwheel (1)
- # luminus (3)
- # om-next (1)
- # parinfer (5)
- # perun (1)
- # planck (1)
- # reagent (5)
- # spacemacs (2)
- # untangled (1)
- # yada (1)
@alexmiller getting weird behavior when trying to conform this:
(s/def ::thing (s/cat
:a (s/? string?)
:b (s/+ number?)))
(s/def ::seq-of (s/+ ::thing))
(s/conform ::seq-of '(”foo” 1 “bar” 2 3 “qux” 4))
;=> [{:a "foo", :b [1]} [{:a "bar", :b [2 3]} {:a "qux", :b [4]}]]
;expected
;=> [{:a "foo", :b [1]} {:a "bar", :b [2 3]} {:a "qux", :b [4]}]
;; ONLY 2nd thing matters?
(s/conform ::seq-of '(”foo” 1 2 “ bar 3))
;=> [{:a "foo", :b [1 2]} {:a "bar", :b [2]}]
;; NO OPTIONAL
(s/def ::thing (s/cat
:a string?
:b (s/+ number?)))
(s/def ::seq-of (s/+ ::thing))
(s/conform ::seq-of '(”foo” 1 “bar” 2 3 “qux” 4))
;=> [{:a "foo", :b [1]} {:a "bar", :b [2 3]} {:a "qux", :b [4]}]
This also only shows up if there are 2+ numbers in the 2nd or later ::thing
AND the problem goes away if I make :a
not optional…
is this at all related to http://dev.clojure.org/jira/browse/CLJ-2003 ?is it possible to “redef” the spec? if I have a spec that depends on other spec and that one uses a function as a predicate and I want to predicate to be something else in the test
@adambros that looks like what phil brown mentions in the comment on that, but alex says it isn't actually related to that issue and he should open a new issue for it
@adambros not sure if that’s the same or not, feel free to log
I’d be grateful for feedback 🙂 https://groups.google.com/forum/#!topic/clojure/wwJVJKtxps8
I ran into some issues with spec.test/check
not terminating when using a coll-of
spec with :kind
:
(s/def ::bar (s/coll-of number? :kind vector?))
(defn foo [a]
(reduce + 0 a))
(s/fdef foo
:args (s/cat :a ::bar)
:ret number?)
(first (stest/check `foo))
The last call does not terminate, just keeps heating my CPU. When removing the :kind vector?
constraint from the spec ::bar
everything works fine. With :kind list?
I also get the erroneous behaviour.Wondering If I am doing something wrong, if this is a bug and if it was filed on Jira already
@nblumoe If you don't provide :into []
to s/coll-of
spec will generate a vector every time just to call empty
on it to then generate the stuff into it. Apparently these "generated constructor vectors" explode and you can't control their sizing. So you have to provide :into
. @alexmiller Is this intended or ticketworthy?
sounds like a ticket to me
Not sure I understand all that without looking at the code but doesn't sound right