Skip to content

Instantly share code, notes, and snippets.

@adolfont
Created March 15, 2016 16:41
Show Gist options
  • Save adolfont/2529cc7f29722e879361 to your computer and use it in GitHub Desktop.
Save adolfont/2529cc7f29722e879361 to your computer and use it in GitHub Desktop.
(ns clojure.test.example
(:use clojure.test))
; Documentation: http://philmaffetone.com/180-formula/
(defn maffetone-formula-max [age]
"Returns 180-age"
(- 180 age))
(deftest maffetone-formula-max-test
(is (= 160 (maffetone-formula-max 20))))
(defn maffetone-formula-min [age]
"Returns maffetone-formula minus 10"
(- (maffetone-formula-max age) 10))
(deftest maffetone-formula-min-test
(is (= 150 (maffetone-formula-min 20))))
(defn maffetone-formula-max [age & args]
"Returns 180-age or 180-age-10 if illness"
(if (contains? #{:illness :medication} (first args)) (- 170 age) (- 180 age)))
(deftest maffetone-formula-max-illness-test
(is (= 150 (maffetone-formula-max 20 :illness))))
(deftest maffetone-formula-max-medication-test
(is (= 150 (maffetone-formula-max 20 :medication))))
(run-tests)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment