Skip to content

Instantly share code, notes, and snippets.

Last active May 25, 2016
What would you like to do?
Trying to write a failing test with check-var
(:require [clojure.spec :as s]
[clojure.spec.test :as test]))
(def suits #{:hearts :diamonds :clubs :spades})
(def ranks (into #{:ace :king :queen :jack} (range 2 11)))
(def cards (for [rank ranks suit suits] [rank suit]))
(s/def ::card (s/cat :rank ranks :suit suits))
(defn value [[rank _]]
(<= 2 rank 10)
(#{:jack :queen :king} rank)
(#{:ace} rank)
[1 11]))
(s/fdef value
:args (s/cat :card ::card)
:ret integer?)
(test/check-var #'value)
;; => nil
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment