Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added total function and wrote some high-level tests
- Loading branch information
Christian Romney
committed
Aug 19, 2011
1 parent
cec6a83
commit a843b20
Showing
4 changed files
with
49 additions
and
8 deletions.
There are no files selected for viewing
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,41 @@ | ||
(ns prisoners.test.core | ||
(:use [prisoners.core]) | ||
(:require [prisoners.core :as pri]) | ||
(:use [clojure.test])) | ||
|
||
(deftest replace-me ;; FIXME: write | ||
(is false "No tests have been written.")) | ||
;; Test Helpers | ||
|
||
(defn score-round [rounds x y] | ||
(map (fn [m] [(:name m) (pri/total m)]) (pri/play-rounds rounds x y))) | ||
|
||
(defn score [x] | ||
(last x)) | ||
|
||
;; Test Expected Outcomes | ||
|
||
(deftest test-cheat-sucker | ||
(let [[x y] (score-round 1 :cheat :sucker)] | ||
(is | ||
(and | ||
(= 5 (score x)) | ||
(= 0 (score y))) ":cheat 5, :sucker 0"))) | ||
|
||
(deftest test-cheat-cheat | ||
(let [[x y] (score-round 1 :cheat :cheat)] | ||
(is | ||
(and | ||
(= 1 (score x)) | ||
(= 1 (score y))) ":cheat 1, :cheat 1"))) | ||
|
||
(deftest test-sucker-sucker | ||
(let [[x y] (score-round 1 :sucker :sucker)] | ||
(is | ||
(and | ||
(= 3 (score x)) | ||
(= 3 (score y))) ":sucker 3, :sucker 3"))) | ||
|
||
(deftest test-cheat-tit-for-tat | ||
(let [[x y] (score-round 2 :cheat :tit-for-tat)] | ||
(is | ||
(and | ||
(= 6 (last x)) | ||
(= 1 (last y))) ":cheat 6, :tit-fot-tat 1"))) |