This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2019-08-12
Channels
- # beginners (102)
- # boot (5)
- # cider (1)
- # cljs-dev (15)
- # cljsjs (1)
- # cljsrn (20)
- # clojure (104)
- # clojure-austin (1)
- # clojure-europe (8)
- # clojure-italy (39)
- # clojure-nl (17)
- # clojure-spec (38)
- # clojure-uk (23)
- # clojurescript (34)
- # cursive (31)
- # data-science (5)
- # datomic (3)
- # emacs (28)
- # joker (1)
- # kaocha (5)
- # klipse (1)
- # leiningen (1)
- # off-topic (66)
- # quil (4)
- # reagent (35)
- # ring-swagger (1)
- # rum (1)
- # shadow-cljs (121)
- # test-check (1)
- # tools-deps (33)
- # uncomplicate (2)
- # vim (15)
- # yada (1)
@alexmiller Thank you. That issue is resolved. I have a new one. Here is a failing example taken from the spec Guide. This is with the latest version 'e58788107ee2ab765a7d46854b2cffd85429e339'.
@norton I'll defer to Alex for the final word but I think that's a case where Spec 2 and Spec 1 differ. I think I ran across something like that when I tried converting our code over to Spec 2...
@seancorfield thank you. I will take another look.
I'm trying a few things locally but it isn't jogging my memory of what I had to do here. So it may be an unintended bug.
Hmm, the more I look at this, the more I think it is a new bug. I pulled up the Spec 2 branch of our code and we have some specs that look very similar to the above and used to work. Right now I can't test the Spec 2 branch on my laptop so I can't dig in any further until tomorrow @norton
@seancorfield Yes, I think so. This type of spec was working with the 'dc960158ccb9cf8b5dc555842eea5e1af12f28c2' commit.
fixed, just missed the expand-spec for with-gen
@alexmiller That fixes the problem reported above, but you can't do (s/exercise ::kws)
-- that produces
user=> (s/exercise ::kws)
Execution error (IllegalArgumentException) at clojure.spec-alpha2.protocols/eval173$fn$G (protocols.clj:11).
No implementation of method: :gen* of protocol: #'clojure.spec-alpha2.protocols/Spec found for class: clojure.lang.PersistentHashSet
user=>
That is a spec 2 difference - the gen needs to wrap s/spec around the set
Ah yes. That was the difference I was thinking of when I first thought this was a Spec 1/2 difference but still couldn't get that example working! /cc @norton
@alexmiller @seancorfield Thank you. The issue above is fixed. There is one more.
fixed, added some tests to catch this and prior
Can you alias a spec to another spec? I have a situation like this where I would like to not repeat the definition of task-state
for both old
and new
:
(s/def ::task-state #{... big set ...})
(s/def ::old ::task-state)
(s/def ::new ::task-state)
(s/def ::event (s/keys :req [::old ::new]))
should work (in spec 1)
Anyone know of guidance around organizing specs and the code being spec’d? E.g., putting specs in the same file as the things being spec’d, or in separate parallel nses, or in a separate common spec ns?
@alexmiller I'm updating our branch to the latest Spec 2 at work and ran into this exception "No implementation of method: :conform* of protocol: #'clojure.spec-alpha2.protocols/Spec found for class: java.lang.String",
-- would that be from this spec: (s/def ::empty-id (s/or :empty #{""} :id ::pos-int))
?
Dunno, would have to take a closer look
I'll try wrapping #{""}
in (s/spec ,,,)
and see if that fixes it... but we have a lot of set-as-predicate specs and this has all worked with earlier Spec 2 builds...
Nope. Problem lies deeper. Digging...
Seems to be related to this
(defmacro param-spec
[coerce str-or-spec & [spec]]
(let [[to-str spec] (if spec [str-or-spec spec] [str str-or-spec])]
`(s/with-gen (s/and (s/conformer ~coerce) ~spec)
(fn [] (g/fmap ~to-str (s/gen ~spec))))))
So it's around dynamically built specs.@seancorfield you shouldn't have to wrap that so I'd say it's a bug if that fixes it :)
it's probably not that it's dynamically built but rather something about what's being built (my first suspicion would be with conformer)
user=> (require '[clojure.spec-alpha2 :as s])
nil
user=> (s/def ::foo (s/keys))
:user/foo
user=> (s/valid? ::foo {"bar" 42})
Execution error (IllegalArgumentException) at clojure.spec-alpha2.protocols/eval13332$fn$G (protocols.clj:11).
No implementation of method: :conform* of protocol: #'clojure.spec-alpha2.protocols/Spec found for class: java.lang.String
user=>
Only fails if the map being checked has string keys, rather than keyword keys.@alexmiller Smallest repro ^
I changed how some of that keys stuff worked, obviously did not test it very well (but not really emphasizing keys as that's going to be replaced by schema/select)
I assume it's trying to check whether unspecified keys conform and not guarding that with a check for whether the key name could actually be a spec?
Switching a large code base from s/keys
to s/schema
/`s/select` will be a massive piece of work so I hope that s/keys
will continue to work while we make those changes 🙂
yeah, I'm trying to keep it working, I'll fix it up