Skip to content

Instantly share code, notes, and snippets.

@eraserhd
Created August 30, 2016 18:51
Show Gist options
  • Save eraserhd/0aca4172b34c3c64f2e17f8c9107174d to your computer and use it in GitHub Desktop.
Save eraserhd/0aca4172b34c3c64f2e17f8c9107174d to your computer and use it in GitHub Desktop.
Weird spec problem
(defn- dependency-indices
[length]
(s/tuple (s/int-in 0 length)
(s/int-in 0 length)))
(defn- index-set
[length]
(s/gen (s/coll-of (dependency-indices length)
:kind set?
:max-count (/ length 2))))
(s/def ::tasks
(s/spec (s/coll-of ::task)
:gen (fn []
(gen/bind
(s/gen (s/coll-of ::task :min-count 5))
(fn [tasks]
;; If we remove the gen/tuple - just make it (gen/return tasks), it runs
;; fast. With the gen/tuple, it says "Couldn't satisfy such-that" consisitently
(gen/tuple (gen/return tasks)))))))
(s/def ::task (s/keys :req [:task.def2/uuid
:task.def2/name]))
(s/def :task.def2/uuid uuid?)
(s/def :task.def2/name (s/and string? not-empty))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment