Skip to content

Instantly share code, notes, and snippets.

@tvanhens
Last active May 25, 2016
Embed
What would you like to do?
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