blob: 81ddedd8677a3774f500927464512bf0b36fe48f (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
|
(let [{: describe
: test-end
: deep-equals
} (require :lib.test)]
;; just a little something to test with
(fn add [x y] (let [x (or x 0)
y (or y 0)]
(+ x y)))
(describe "# TEST" (fn []
(describe "add()" (fn [test]
(let [should "return the right number"]
(test {:given "two numbers"
: should
:actual (add 2 3)
:expected 5})
(test {:given "no arguments"
:should "return 0"
:actual (add)
:expected 0})
(test {:given "zero"
: should
:actual (add 0 4)
:expected 4}))))
(describe "equal()" (fn [t]
(t {:given "two equal tables"
:should "return true"
:expected true
:actual (deep-equals [:orange :apple :pear] [:orange :apple :pear]) })
(t {:given "two different tables"
:should "return false"
:expected false
:actual (deep-equals [:apple :pear] [:orange :apple :pear]) })
(t {:given "equal strings"
:should "be true"
:expected true
:actual (deep-equals :apple :apple) })
(t {:given "different strings"
:should "be false"
:expected false
:actual (deep-equals :apple :pear) })
(t {:given "equal bools"
:should "be true"
:expected true
:actual (deep-equals true true) })
(t {:given "different strings"
:should "be false"
:expected false
:actual (deep-equals true false) })))
(test-end))))
|