Trying to write a failing test with check-var
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
(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