This repository has been archived by the owner on Jun 29, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
test.sibilant
37 lines (36 loc) · 2.09 KB
/
test.sibilant
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
(var {is test-runner arrays-equal? objects-equal?} (require "./infintestimal")
arrays [["Empty arrays are equal"
(#> (is true (arrays-equal? [] [])))]
["Arrays with the same contents are equal"
(#> (is true (arrays-equal? [1 2] [1 2])))]
["Arrays of different lengths are not equal"
(#> (is false (arrays-equal? [1 1] [1 1 1])))]
["An array that is a subset of another are not equal"
(#> (is false (arrays-equal? [1 2] [1])))]
["An array that is a superset of another are not equal"
(#> (is false (arrays-equal? [1 2] [1 2 3])))]
["Arrays of the same length with different contents are not equal"
(#> (is false (arrays-equal? [1 2] [1 3])))]]
objects [["Empty objects are equal"
(#> (is true (objects-equal? {} {})))]
["Objects with the same attributes and values are equal"
(#> (is true (objects-equal? {'a 1} {'a 1})))]
["Objects with the same attributes but different values are not equal"
(#> (is false (objects-equal? {'a 1} {'a 2})))]
["Objects with the same attributes and values in a different order are equal"
(#> (is true (objects-equal? {'a 1 'b 2} {'b 2 'a 1})))]
["Objects with different attributes and values are not equal"
(#> (is false (objects-equal? {'a 1} {'b 2})))]]
is-tests [["Is can compare arrays"
(#> (is [1 2] [1 2]))]
["Is can compare objects"
(#> (is {'a 1} {'a 1}))]]
async-test [["We can test things that don't immediately return"
(# (done)
(var expected "cat")
(set-timeout (#> (done (is expected 'cat))) 1000))]
["We can test other things, which won't slow each other down"
(# (done)
(var expected 1)
(set-timeout (#> (done (is expected 1))) 100))]])
(each test [arrays objects is-tests async-test] (test-runner test))