-
-
Notifications
You must be signed in to change notification settings - Fork 159
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
aec57b5
commit 7296e32
Showing
4 changed files
with
99 additions
and
69 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
(ns space-age-generator | ||
(:require [hbs.helper :refer [safe-str]] | ||
[clojure.string :as str])) | ||
|
||
(defn update-test-case [test-case] | ||
(update-in test-case [:input :planet] #(safe-str (str/lower-case %)))) |
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 |
---|---|---|
@@ -0,0 +1,14 @@ | ||
(ns space-age-test | ||
(:require [clojure.test :refer [deftest testing is]] | ||
space-age)) | ||
|
||
(defn- rounds-to | ||
[expected actual] | ||
(is (= (Math/round (* 100.0 expected)) | ||
(Math/round (* 100.0 actual))))) | ||
|
||
{{#test_cases.age}} | ||
(deftest on-{{input.planet}}_test_1 | ||
(testing {{description}} | ||
(rounds-to {{expected}} (space-age/on-{{input.planet}} {{input.seconds}})))) | ||
{{/test_cases.age~}} |
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,33 +1,49 @@ | ||
(ns space-age) | ||
|
||
(defn on-mercury [] ;; <- arglist goes here | ||
;; your code goes here | ||
) | ||
|
||
(defn on-venus [] ;; <- arglist goes here | ||
;; your code goes here | ||
) | ||
|
||
(defn on-earth [] ;; <- arglist goes here | ||
;; your code goes here | ||
) | ||
|
||
(defn on-mars [] ;; <- arglist goes here | ||
;; your code goes here | ||
) | ||
|
||
(defn on-jupiter [] ;; <- arglist goes here | ||
;; your code goes here | ||
) | ||
|
||
(defn on-saturn [] ;; <- arglist goes here | ||
;; your code goes here | ||
) | ||
|
||
(defn on-uranus [] ;; <- arglist goes here | ||
;; your code goes here | ||
) | ||
|
||
(defn on-neptune [] ;; <- arglist goes here | ||
;; your code goes here | ||
) | ||
(defn on-mercury | ||
"Returns someone's age on Mercury based on the given age in seconds" | ||
[seconds] | ||
;; function body | ||
) | ||
|
||
(defn on-venus | ||
"Returns someone's age on Venus based on the given age in seconds" | ||
[seconds] | ||
;; function body | ||
) | ||
|
||
(defn on-earth | ||
"Returns someone's age on Earth based on the given age in seconds" | ||
[seconds] | ||
;; function body | ||
) | ||
|
||
(defn on-mars | ||
"Returns someone's age on Mars based on the given age in seconds" | ||
[seconds] | ||
;; function body | ||
) | ||
|
||
(defn on-jupiter | ||
"Returns someone's age on Jupiter based on the given age in seconds" | ||
[seconds] | ||
;; function body | ||
) | ||
|
||
(defn on-saturn | ||
"Returns someone's age on Saturn based on the given age in seconds" | ||
[seconds] | ||
;; function body | ||
) | ||
|
||
(defn on-uranus | ||
"Returns someone's age on Uranus based on the given age in seconds" | ||
[seconds] | ||
;; function body | ||
) | ||
|
||
(defn on-neptune | ||
"Returns someone's age on Neptune based on the given age in seconds" | ||
[seconds] | ||
;; function body | ||
) |
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,46 +1,40 @@ | ||
(ns space-age-test | ||
(:require [clojure.test :refer [deftest is]] | ||
(:require [clojure.test :refer [deftest testing is]] | ||
space-age)) | ||
|
||
(defn- rounds-to | ||
[expected actual] | ||
(is (= (Math/round (* 100.0 expected)) | ||
(Math/round (* 100.0 actual))))) | ||
|
||
(deftest age-in-earth-years | ||
(rounds-to 31.69 (space-age/on-earth 1000000000))) | ||
|
||
(deftest age-in-mercury-years | ||
(let [seconds 2134835688] | ||
(rounds-to 67.65 (space-age/on-earth seconds)) | ||
(rounds-to 280.88 (space-age/on-mercury seconds)))) | ||
|
||
(deftest age-in-venus-years | ||
(let [seconds 189839836] | ||
(rounds-to 6.02 (space-age/on-earth seconds)) | ||
(rounds-to 9.78 (space-age/on-venus seconds)))) | ||
|
||
(deftest age-on-mars | ||
(let [seconds 2329871239] | ||
(rounds-to 73.83 (space-age/on-earth seconds)) | ||
(rounds-to 39.25 (space-age/on-mars seconds)))) | ||
|
||
(deftest age-on-jupiter | ||
(let [seconds 901876382] | ||
(rounds-to 28.58 (space-age/on-earth seconds)) | ||
(rounds-to 2.41 (space-age/on-jupiter seconds)))) | ||
|
||
(deftest age-on-saturn | ||
(let [seconds 3000000000] | ||
(rounds-to 95.06 (space-age/on-earth seconds)) | ||
(rounds-to 3.23 (space-age/on-saturn seconds)))) | ||
|
||
(deftest age-on-uranus | ||
(let [seconds 3210123456] | ||
(rounds-to 101.72 (space-age/on-earth seconds)) | ||
(rounds-to 1.21 (space-age/on-uranus seconds)))) | ||
|
||
(deftest age-on-neptune | ||
(let [seconds 8210123456] | ||
(rounds-to 260.16 (space-age/on-earth seconds)) | ||
(rounds-to 1.58 (space-age/on-neptune seconds)))) | ||
(deftest on-earth_test_1 | ||
(testing "age on Earth" | ||
(rounds-to 31.69 (space-age/on-earth 1000000000)))) | ||
|
||
(deftest on-mercury_test_1 | ||
(testing "age on Mercury" | ||
(rounds-to 280.88 (space-age/on-mercury 2134835688)))) | ||
|
||
(deftest on-venus_test_1 | ||
(testing "age on Venus" | ||
(rounds-to 9.78 (space-age/on-venus 189839836)))) | ||
|
||
(deftest on-mars_test_1 | ||
(testing "age on Mars" | ||
(rounds-to 35.88 (space-age/on-mars 2129871239)))) | ||
|
||
(deftest on-jupiter_test_1 | ||
(testing "age on Jupiter" | ||
(rounds-to 2.41 (space-age/on-jupiter 901876382)))) | ||
|
||
(deftest on-saturn_test_1 | ||
(testing "age on Saturn" | ||
(rounds-to 2.15 (space-age/on-saturn 2000000000)))) | ||
|
||
(deftest on-uranus_test_1 | ||
(testing "age on Uranus" | ||
(rounds-to 0.46 (space-age/on-uranus 1210123456)))) | ||
|
||
(deftest on-neptune_test_1 | ||
(testing "age on Neptune" | ||
(rounds-to 0.35 (space-age/on-neptune 1821023456)))) |