Fork me on GitHub

@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]}]]

;=> [{: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]}]

(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 ?


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


a cons somewhere there should be a concat

Alex Miller (Clojure team)00:01:52

@adambros not sure if that’s the same or not, feel free to log


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 try adding :gen-max 3 to the ::bar definition


it could be that it is generating some crazy big collections


thanks, but still the same issue


@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

Alex Miller (Clojure team)23:01:04

Not sure I understand all that without looking at the code but doesn't sound right