Last active
March 31, 2017 16:21
-
-
Save rads/89d820e70838d99850a6a2c71e82e0d6 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(set-env! | |
:dependencies '[[org.clojure/clojure "1.9.0-alpha15"] | |
[org.clojure/test.check "0.9.0"]]) | |
(require | |
'[clojure.spec :as s] | |
'[clojure.spec.test :as stest]) | |
(s/def ::printer fn?) | |
(s/def ::name (s/and string? seq)) | |
(s/def ::result #{:ok :error}) | |
(defn run [printer name] | |
(if-not (printer name) | |
:ok | |
:error)) | |
(s/fdef run | |
:args (s/cat :printer ::printer | |
:name ::name) | |
:ret ::result) | |
(stest/instrument `run) | |
(defn print-name [name] | |
(println (str "Name: " name))) | |
(run print-name "foo") | |
;; Start a REPL | |
; $ BOOT_CLOJURE_VERSION=1.9.0-alpha15 boot repl | |
;; Run the example | |
; boot.user=> (load-file "clojure-spec-instrument-hof.clj") | |
; Name: 9S | |
; Name: Yx | |
; Name: N | |
; Name: CF4 | |
; Name: 1b | |
; Name: b6PP6 | |
; Name: 2Cv | |
; Name: s2lz | |
; Name: oW7sX9l | |
; Name: Ka7 | |
; Name: qFr1 | |
; Name: HotQBQWyDy | |
; Name: 2C10SJD | |
; Name: D7CPdaE4 | |
; Name: FbKA0 | |
; Name: 3VUqa | |
; Name: YUJou119X6gY14l3 | |
; Name: tdp | |
; Name: iMH0V7huV5Br11D2 | |
; Name: QKFQHnFz1TF926G0xV7 | |
; Name: e36e2h8B0y5XkMb0Tq95 | |
; Name: foo | |
; :ok |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment