(deftest arithmetic-works
(testing "with positive integers"
(is (= (+ 2 2) 4))
(is (= (+ 3 4) 7)))
(facts "on arithmetic"
(fact "you can sum positive integers"
(+ 2 2) => 4
(+ 1000 1000 1000 1000)
=> 4000))
Funcção
(defn points [player]
(case (compute-status player)
:won 100
:draw 10
:lost 0))
Teste
(fact "a winner player gets 100 points"
(points "plínio") => 100
(provided
(compute-status "plínio") => :won))
(fact (+ 3 4) => prime?)
(facts
(empty? []) => truthy
(empty? [3]) => falsey)
(fact "the universe won't divide"
(/ 1 0) => (throws Exception))
(fact
(range 10) => (contains 5) ;; [0, 1, 2, 3, ..., 9]
(range 3) => (just [even? odd? even?]))
(fact
{:age 27 :laughter "huahue"} => (contains {:age #(>= % 18)})
{:age 27 :laughter "huahue"} => (just {:age #(>= % 18)
:laughter #"(hu[a|e])+"}))
(fact
#{:foo :bar} => (contains :foo)
#{:foo :bar} => (two-of keyword?))
(fact
(room-temperature) => (roughly 25 3)
(provided
(object-temperature) =streams=> [85 86 87]))
(fact
(gen-positive-number) =not=> #(< % 0))
(defn burger-combo [burger]
{:burger burger :free-drink (cheapest-drink)})
(fact "you get a free drink with the combo"
(burger-combo "delicious burger")
=contains=> {:free-drink "delicious drink"}
(provided (cheapest-drink) => "delicious drink"))
(fact "you get a free drink with the combo"
(burger-combo ..some-burger..)
=contains=> {:free-drink ..some-drink..}
(provided (cheapest-drink) => ..some-drink..))
(fact "the charge with the highest value is charged in the end"
(divide-charges 9) => [4 5])
(tabular (fact "..."
(divide-charges ?total) => [?1st ?2nd])
?total ?1st ?2nd
100 50 50
99 49 50)
1. Programming by wishful thinking(defn format-page [...] (format-paragraph ...) ...)
2. REPLuser> (format-paragraph ..foo...) ..bar.. user>
(format-paragraph ..foo..) => ..bar..
> lein midje :autotest
...
> lein midje :autotest
...
====================================
Loading (foo.bar)
FAIL at (bar.clj:42)
Expected: 5
Actual: 4
FAILURE: 1 check failed. (But 1337 succeeded.)