Newer
Older
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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
(import ./lib :as t)
(def things-ran @[])
(t/group
"test/lib.janet works"
(fn []
(t/before (fn [] (array/push things-ran 'before)))
(t/before-each (fn [] (array/push things-ran 'before-each)))
(t/test
"this should pass"
(fn []
(array/push things-ran 'passing-test)
(assert true)))
(t/test
"this should fail"
(fn []
(array/push things-ran 'failing-test)
(assert false)))
(t/after (fn [] (array/push things-ran 'after)))
(t/after-each (fn [] (array/push things-ran 'after-each)))))
(t/run-tests :exit-on-failure false)
(assert (deep= things-ran @['before
'before-each
'passing-test
'after-each
'before-each
'failing-test
'after-each
'after]))
# implicit group
(t/reset)
(array/clear things-ran)
(t/before (fn [] (array/push things-ran 'before)))
(t/before-each (fn [] (array/push things-ran 'before-each)))
(t/test
"this should pass"
(fn []
(array/push things-ran 'passing-test)
(assert true)))
(t/test
"this should fail"
(fn []
(array/push things-ran 'failing-test)
(assert false)))
(t/after (fn [] (array/push things-ran 'after)))
(t/after-each (fn [] (array/push things-ran 'after-each)))
(t/run-tests :exit-on-failure false)
(assert (deep= things-ran @['before
'before-each
'passing-test
'after-each
'before-each
'failing-test
'after-each
'after]))