Skip to content

Instantly share code, notes, and snippets.

@mfikes
Created June 20, 2017 17:40
Show Gist options
  • Save mfikes/1caa83751019495cfdda83e79ad7e3ed to your computer and use it in GitHub Desktop.
Save mfikes/1caa83751019495cfdda83e79ad7e3ed to your computer and use it in GitHub Desktop.
$ lein repl
nREPL server started on port 55862 on host 127.0.0.1 - nrepl://127.0.0.1:55862
REPL-y 0.3.7, nREPL 0.2.12
Clojure 1.9.0-alpha17
Java HotSpot(TM) 64-Bit Server VM 1.8.0_131-b11
Docs: (doc function-name-here)
(find-doc "part-of-name-here")
Source: (source function-name-here)
Javadoc: (javadoc java-object-or-class-here)
Exit: Control+D or (exit) or (quit)
Results: Stored in vars *1, *2, *3, an exception in *e
user=> (require '[clojure.spec.alpha :as s]
#_=> '[clojure.spec.test.alpha :as st])
nil
user=> (defn ranged-rand [start end] 0)
#'user/ranged-rand
user=> (s/fdef ranged-rand
#_=> :args (s/and (s/cat :start int? :end int?)
#_=> #(< (:start %) (:end %)))
#_=> :ret int?
#_=> :fn (s/and #(>= (:ret %) (-> % :args :start))
#_=> #(< (:ret %) (-> % :args :end))))
user/ranged-rand
user=> (st/check `ranged-rand)
({:spec #object[clojure.spec.alpha$fspec_impl$reify__1215 0x32d9f74d "clojure.spec.alpha$fspec_impl$reify__1215@32d9f74d"], :clojure.spec.test.check/ret {:result #error {
:cause "Specification-based check failed"
:data {:clojure.spec.alpha/problems [{:path [:fn], :pred (clojure.core/fn [%] (clojure.core/< (:ret %) (clojure.core/-> % :args :end))), :val {:args {:start -1, :end 0}, :ret 0}, :via [], :in []}], :clojure.spec.alpha/spec #object[clojure.spec.alpha$and_spec_impl$reify__875 0x2f75ef6f "clojure.spec.alpha$and_spec_impl$reify__875@2f75ef6f"], :clojure.spec.alpha/value {:args {:start -1, :end 0}, :ret 0}, :clojure.spec.test.alpha/args (-1 0), :clojure.spec.test.alpha/val {:args {:start -1, :end 0}, :ret 0}, :clojure.spec.alpha/failure :check-failed}
:via
[{:type clojure.lang.ExceptionInfo
:message "Specification-based check failed"
:data {:clojure.spec.alpha/problems [{:path [:fn], :pred (clojure.core/fn [%] (clojure.core/< (:ret %) (clojure.core/-> % :args :end))), :val {:args {:start -1, :end 0}, :ret 0}, :via [], :in []}], :clojure.spec.alpha/spec #object[clojure.spec.alpha$and_spec_impl$reify__875 0x2f75ef6f "clojure.spec.alpha$and_spec_impl$reify__875@2f75ef6f"], :clojure.spec.alpha/value {:args {:start -1, :end 0}, :ret 0}, :clojure.spec.test.alpha/args (-1 0), :clojure.spec.test.alpha/val {:args {:start -1, :end 0}, :ret 0}, :clojure.spec.alpha/failure :check-failed}
:at [clojure.core$ex_info invokeStatic "core.clj" 4725]}]
:trace
[[clojure.core$ex_info invokeStatic "core.clj" 4725]
[clojure.core$ex_info invoke "core.clj" 4725]
[clojure.spec.test.alpha$explain_check invokeStatic "alpha.clj" 277]
[clojure.spec.test.alpha$explain_check invoke "alpha.clj" 275]
[clojure.spec.test.alpha$check_call invokeStatic "alpha.clj" 299]
[clojure.spec.test.alpha$check_call invoke "alpha.clj" 285]
[clojure.spec.test.alpha$quick_check$fn__1395 invoke "alpha.clj" 308]
[clojure.lang.AFn applyToHelper "AFn.java" 154]
[clojure.lang.AFn applyTo "AFn.java" 144]
[clojure.core$apply invokeStatic "core.clj" 657]
[clojure.core$apply invoke "core.clj" 652]
[clojure.test.check.properties$apply_gen$fn__2151$fn__2152 invoke "properties.cljc" 16]
[clojure.test.check.properties$apply_gen$fn__2151 invoke "properties.cljc" 16]
[clojure.test.check.rose_tree$fmap invokeStatic "rose_tree.cljc" 78]
[clojure.test.check.rose_tree$fmap invoke "rose_tree.cljc" 74]
[clojure.test.check.generators$fmap$fn__1738 invoke "generators.cljc" 89]
[clojure.test.check.generators$gen_fmap$fn__1712 invoke "generators.cljc" 55]
[clojure.test.check.generators$call_gen invokeStatic "generators.cljc" 41]
[clojure.test.check.generators$call_gen invoke "generators.cljc" 38]
[clojure.test.check$quick_check invokeStatic "check.cljc" 62]
[clojure.test.check$quick_check doInvoke "check.cljc" 37]
[clojure.lang.RestFn invoke "RestFn.java" 425]
[clojure.lang.AFn applyToHelper "AFn.java" 156]
[clojure.lang.RestFn applyTo "RestFn.java" 132]
[clojure.core$apply invokeStatic "core.clj" 657]
[clojure.core$apply invoke "core.clj" 652]
[clojure.spec.gen.alpha$quick_check invokeStatic "alpha.clj" 29]
[clojure.spec.gen.alpha$quick_check doInvoke "alpha.clj" 27]
[clojure.lang.RestFn applyTo "RestFn.java" 137]
[clojure.core$apply invokeStatic "core.clj" 661]
[clojure.core$apply invoke "core.clj" 652]
[clojure.spec.test.alpha$quick_check invokeStatic "alpha.clj" 309]
[clojure.spec.test.alpha$quick_check invoke "alpha.clj" 302]
[clojure.spec.test.alpha$check_1 invokeStatic "alpha.clj" 335]
[clojure.spec.test.alpha$check_1 invoke "alpha.clj" 323]
[clojure.spec.test.alpha$check$fn__1414 invoke "alpha.clj" 411]
[clojure.core$pmap$fn__7907$fn__7908 invoke "core.clj" 6897]
[clojure.core$binding_conveyor_fn$fn__5297 invoke "core.clj" 2027]
[clojure.lang.AFn call "AFn.java" 18]
[java.util.concurrent.FutureTask run "FutureTask.java" 266]
[java.util.concurrent.ThreadPoolExecutor runWorker "ThreadPoolExecutor.java" 1142]
[java.util.concurrent.ThreadPoolExecutor$Worker run "ThreadPoolExecutor.java" 617]
[java.lang.Thread run "Thread.java" 748]]}, :seed 1497979970176, :failing-size 0, :num-tests 1, :fail [(-1 0)], :shrunk {:total-nodes-visited 0, :depth 0, :result #error {
:cause "Specification-based check failed"
:data {:clojure.spec.alpha/problems [{:path [:fn], :pred (clojure.core/fn [%] (clojure.core/< (:ret %) (clojure.core/-> % :args :end))), :val {:args {:start -1, :end 0}, :ret 0}, :via [], :in []}], :clojure.spec.alpha/spec #object[clojure.spec.alpha$and_spec_impl$reify__875 0x2f75ef6f "clojure.spec.alpha$and_spec_impl$reify__875@2f75ef6f"], :clojure.spec.alpha/value {:args {:start -1, :end 0}, :ret 0}, :clojure.spec.test.alpha/args (-1 0), :clojure.spec.test.alpha/val {:args {:start -1, :end 0}, :ret 0}, :clojure.spec.alpha/failure :check-failed}
:via
[{:type clojure.lang.ExceptionInfo
:message "Specification-based check failed"
:data {:clojure.spec.alpha/problems [{:path [:fn], :pred (clojure.core/fn [%] (clojure.core/< (:ret %) (clojure.core/-> % :args :end))), :val {:args {:start -1, :end 0}, :ret 0}, :via [], :in []}], :clojure.spec.alpha/spec #object[clojure.spec.alpha$and_spec_impl$reify__875 0x2f75ef6f "clojure.spec.alpha$and_spec_impl$reify__875@2f75ef6f"], :clojure.spec.alpha/value {:args {:start -1, :end 0}, :ret 0}, :clojure.spec.test.alpha/args (-1 0), :clojure.spec.test.alpha/val {:args {:start -1, :end 0}, :ret 0}, :clojure.spec.alpha/failure :check-failed}
:at [clojure.core$ex_info invokeStatic "core.clj" 4725]}]
:trace
[[clojure.core$ex_info invokeStatic "core.clj" 4725]
[clojure.core$ex_info invoke "core.clj" 4725]
[clojure.spec.test.alpha$explain_check invokeStatic "alpha.clj" 277]
[clojure.spec.test.alpha$explain_check invoke "alpha.clj" 275]
[clojure.spec.test.alpha$check_call invokeStatic "alpha.clj" 299]
[clojure.spec.test.alpha$check_call invoke "alpha.clj" 285]
[clojure.spec.test.alpha$quick_check$fn__1395 invoke "alpha.clj" 308]
[clojure.lang.AFn applyToHelper "AFn.java" 154]
[clojure.lang.AFn applyTo "AFn.java" 144]
[clojure.core$apply invokeStatic "core.clj" 657]
[clojure.core$apply invoke "core.clj" 652]
[clojure.test.check.properties$apply_gen$fn__2151$fn__2152 invoke "properties.cljc" 16]
[clojure.test.check.properties$apply_gen$fn__2151 invoke "properties.cljc" 16]
[clojure.test.check.rose_tree$fmap invokeStatic "rose_tree.cljc" 78]
[clojure.test.check.rose_tree$fmap invoke "rose_tree.cljc" 74]
[clojure.test.check.generators$fmap$fn__1738 invoke "generators.cljc" 89]
[clojure.test.check.generators$gen_fmap$fn__1712 invoke "generators.cljc" 55]
[clojure.test.check.generators$call_gen invokeStatic "generators.cljc" 41]
[clojure.test.check.generators$call_gen invoke "generators.cljc" 38]
[clojure.test.check$quick_check invokeStatic "check.cljc" 62]
[clojure.test.check$quick_check doInvoke "check.cljc" 37]
[clojure.lang.RestFn invoke "RestFn.java" 425]
[clojure.lang.AFn applyToHelper "AFn.java" 156]
[clojure.lang.RestFn applyTo "RestFn.java" 132]
[clojure.core$apply invokeStatic "core.clj" 657]
[clojure.core$apply invoke "core.clj" 652]
[clojure.spec.gen.alpha$quick_check invokeStatic "alpha.clj" 29]
[clojure.spec.gen.alpha$quick_check doInvoke "alpha.clj" 27]
[clojure.lang.RestFn applyTo "RestFn.java" 137]
[clojure.core$apply invokeStatic "core.clj" 661]
[clojure.core$apply invoke "core.clj" 652]
[clojure.spec.test.alpha$quick_check invokeStatic "alpha.clj" 309]
[clojure.spec.test.alpha$quick_check invoke "alpha.clj" 302]
[clojure.spec.test.alpha$check_1 invokeStatic "alpha.clj" 335]
[clojure.spec.test.alpha$check_1 invoke "alpha.clj" 323]
[clojure.spec.test.alpha$check$fn__1414 invoke "alpha.clj" 411]
[clojure.core$pmap$fn__7907$fn__7908 invoke "core.clj" 6897]
[clojure.core$binding_conveyor_fn$fn__5297 invoke "core.clj" 2027]
[clojure.lang.AFn call "AFn.java" 18]
[java.util.concurrent.FutureTask run "FutureTask.java" 266]
[java.util.concurrent.ThreadPoolExecutor runWorker "ThreadPoolExecutor.java" 1142]
[java.util.concurrent.ThreadPoolExecutor$Worker run "ThreadPoolExecutor.java" 617]
[java.lang.Thread run "Thread.java" 748]]}, :smallest [(-1 0)]}}, :sym user/ranged-rand, :failure #error {
:cause "Specification-based check failed"
:data {:clojure.spec.alpha/problems [{:path [:fn], :pred (clojure.core/fn [%] (clojure.core/< (:ret %) (clojure.core/-> % :args :end))), :val {:args {:start -1, :end 0}, :ret 0}, :via [], :in []}], :clojure.spec.alpha/spec #object[clojure.spec.alpha$and_spec_impl$reify__875 0x2f75ef6f "clojure.spec.alpha$and_spec_impl$reify__875@2f75ef6f"], :clojure.spec.alpha/value {:args {:start -1, :end 0}, :ret 0}, :clojure.spec.test.alpha/args (-1 0), :clojure.spec.test.alpha/val {:args {:start -1, :end 0}, :ret 0}, :clojure.spec.alpha/failure :check-failed}
:via
[{:type clojure.lang.ExceptionInfo
:message "Specification-based check failed"
:data {:clojure.spec.alpha/problems [{:path [:fn], :pred (clojure.core/fn [%] (clojure.core/< (:ret %) (clojure.core/-> % :args :end))), :val {:args {:start -1, :end 0}, :ret 0}, :via [], :in []}], :clojure.spec.alpha/spec #object[clojure.spec.alpha$and_spec_impl$reify__875 0x2f75ef6f "clojure.spec.alpha$and_spec_impl$reify__875@2f75ef6f"], :clojure.spec.alpha/value {:args {:start -1, :end 0}, :ret 0}, :clojure.spec.test.alpha/args (-1 0), :clojure.spec.test.alpha/val {:args {:start -1, :end 0}, :ret 0}, :clojure.spec.alpha/failure :check-failed}
:at [clojure.core$ex_info invokeStatic "core.clj" 4725]}]
:trace
[[clojure.core$ex_info invokeStatic "core.clj" 4725]
[clojure.core$ex_info invoke "core.clj" 4725]
[clojure.spec.test.alpha$explain_check invokeStatic "alpha.clj" 277]
[clojure.spec.test.alpha$explain_check invoke "alpha.clj" 275]
(defproject try-tc-alpha "0.1.0-SNAPSHOT"
[clojure.spec.test.alpha$check_call invokeStatic "alpha.clj" 299]
[clojure.spec.test.alpha$check_call invoke "alpha.clj" 285]
[clojure.spec.test.alpha$quick_check$fn__1395 invoke "alpha.clj" 308]
[clojure.lang.AFn applyToHelper "AFn.java" 154]
[clojure.lang.AFn applyTo "AFn.java" 144]
[clojure.core$apply invokeStatic "core.clj" 657]
[clojure.core$apply invoke "core.clj" 652]
[clojure.test.check.properties$apply_gen$fn__2151$fn__2152 invoke "properties.cljc" 16]
[clojure.test.check.properties$apply_gen$fn__2151 invoke "properties.cljc" 16]
[clojure.test.check.rose_tree$fmap invokeStatic "rose_tree.cljc" 78]
[clojure.test.check.rose_tree$fmap invoke "rose_tree.cljc" 74]
[clojure.test.check.generators$fmap$fn__1738 invoke "generators.cljc" 89]
[clojure.test.check.generators$gen_fmap$fn__1712 invoke "generators.cljc" 55]
[clojure.test.check.generators$call_gen invokeStatic "generators.cljc" 41]
[clojure.test.check.generators$call_gen invoke "generators.cljc" 38]
[clojure.test.check$quick_check invokeStatic "check.cljc" 62]
[clojure.test.check$quick_check doInvoke "check.cljc" 37]
[clojure.lang.RestFn invoke "RestFn.java" 425]
[clojure.lang.AFn applyToHelper "AFn.java" 156]
[clojure.lang.RestFn applyTo "RestFn.java" 132]
[clojure.core$apply invokeStatic "core.clj" 657]
[clojure.core$apply invoke "core.clj" 652]
[clojure.spec.gen.alpha$quick_check invokeStatic "alpha.clj" 29]
[clojure.spec.gen.alpha$quick_check doInvoke "alpha.clj" 27]
[clojure.lang.RestFn applyTo "RestFn.java" 137]
[clojure.core$apply invokeStatic "core.clj" 661]
[clojure.core$apply invoke "core.clj" 652]
[clojure.spec.test.alpha$quick_check invokeStatic "alpha.clj" 309]
[clojure.spec.test.alpha$quick_check invoke "alpha.clj" 302]
[clojure.spec.test.alpha$check_1 invokeStatic "alpha.clj" 335]
[clojure.spec.test.alpha$check_1 invoke "alpha.clj" 323]
[clojure.spec.test.alpha$check$fn__1414 invoke "alpha.clj" 411]
[clojure.core$pmap$fn__7907$fn__7908 invoke "core.clj" 6897]
[clojure.core$binding_conveyor_fn$fn__5297 invoke "core.clj" 2027]
[clojure.lang.AFn call "AFn.java" 18]
[java.util.concurrent.FutureTask run "FutureTask.java" 266]
[java.util.concurrent.ThreadPoolExecutor runWorker "ThreadPoolExecutor.java" 1142]
[java.util.concurrent.ThreadPoolExecutor$Worker run "ThreadPoolExecutor.java" 617]
[java.lang.Thread run "Thread.java" 748]]}})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment