Skip to content

Instantly share code, notes, and snippets.

@tvanhens
Last active May 25, 2016 22:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tvanhens/28b7f744d799910750d8ae3942680997 to your computer and use it in GitHub Desktop.
Save tvanhens/28b7f744d799910750d8ae3942680997 to your computer and use it in GitHub Desktop.
Trying to write a failing test with check-var
(ns blackjack.game-test
(: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 _]]
(cond
(<= 2 rank 10)
rank
(#{:jack :queen :king} rank)
10
(#{:ace} rank)
[1 11]))
(s/fdef value
:args (s/cat :card ::card)
:ret integer?)
(s/instrument-all)
(test/check-var #'value)
;; => nil
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment