Hello,
I've written a spec with an attached generator. The generator works ONLY if
I rename the spec (yes, the keyword), this is really weird.
-------
Environment :
> java -version
openjdk version "1.8.0_144"
OpenJDK Runtime Environment (build 1.8.0_144-b01)
OpenJDK 64-Bit Server VM (build 25.144-b01, mixed mode)
[org.clojure/clojure "1.9.0-beta1"]
[org.clojure/test.check "0.10.0-alpha2" :scope "test"]
--------
Full code :
(ns myns.specs
(:require [clojure.spec.alpha :as s]
[clojure.string :as str]
[clojure.test.check.generators :as g]))
(def url-path (g/fmap #(apply str "/" %) (g/vector g/char-alphanumeric 5
10)))
(s/def :url/path (s/with-gen (s/and string? #(re-matches #"^(/.*)+" %))
(fn path-gen []
(g/fmap #(apply str %) (g/vector url-path 1
3)))))
--------
Generation fails :
(g/sample (s/gen :url/path) 3)
clojure.lang.ExceptionInfo: Couldn't satisfy such-that predicate after 100
tries.
--------
If I rename `:url/path` to `:url/path2` or `::path`, it works fine !
I tried searching the source code of spec to see if there was already a
spec with the same name, but there was none. I have no idea where this
problem comes from. Any help appreciated.
--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to [email protected]
Note that posts from new members are moderated - please be patient with your
first post.
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
---
You received this message because you are subscribed to the Google Groups
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.