I'm in the process of updating that part of the guide right now, should be done by end of day.
On Wednesday, June 15, 2016 at 12:30:55 PM UTC-5, webber wrote: > > Maybe, the following is the same reason. > > ``` > (defn ranged-rand ;; BROKEN! > "Returns random integer in range start <= rand < end" > [start end] > (+ start (rand-int (- start end)))) > > (s/fdef ranged-rand > :args (s/and (s/cat :start integer? :end integer?) > #(< (:start %) (:end %))) > :ret integer? > :fn (s/and #(>= (:ret %) (-> % :args :start)) > #(< (:ret %) (-> % :args :end)))) > (ranged-rand 8 10) > ;;=> ExceptionInfo Call to #'spec-example.core/ranged-rand did not conform > to spec: > ;;=> At: [:fn] val: {:args {:start 8, :end 10}, :ret 7} fails predicate: > (>= (:ret %) (-> % :args :start)) > ;;=> :clojure.spec/args (8 10) > ;;=> clojure.core/ex-info (core.clj:4617) > (println *clojure-version*) > ;;=> {:major 1, :minor 9, :incremental 0, :qualifier alpha1} > > (s/instrument #'ranged-rand) > (ranged-rand 8 10) > ;;=> 7 > (println *clojure-version*) > ;;=> {:major 1, :minor 9, :incremental 0, :qualifier alpha6} > ``` > > >> user=> (require '[clojure.spec :as s]) >> user=> (defn dummy [x] (if x "yes" "no")) >> user=> (s/fdef dummy >> #_=> :args (s/cat :x integer?) >> #_=> :ret integer?) >> user=> (s/instrument #'dummy) >> user=> (dummy 3) (println *clojure-version*) >> ExceptionInfo Call to #'user/dummy did not conform to spec: >> val: "yes" fails at: [:ret] predicate: integer? >> :clojure.spec/args (3) >> clojure.core/ex-info (core.clj:4703) >> {:major 1, :minor 9, :incremental 0, :qualifier alpha5} >> >> ;------------------------------------------------------------------- >> >> user=> (dummy 3) (println *clojure-version*) >> "yes" >> {:major 1, :minor 9, :incremental 0, :qualifier alpha6} >> > -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com 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 clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.