-
Notifications
You must be signed in to change notification settings - Fork 13
/
test.arc
35 lines (28 loc) · 847 Bytes
/
test.arc
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
(use arc equal-wrt-testing)
(def test-iso (desc result expected)
(if (equal-wrt-testing expected result)
(do (pr "ok " desc " => ")
(write result)
(prn))
(do (pr "FAIL " desc " => ")
(write result)
(pr ", not the expected result ")
(write expected)
(prn)
(err "test failed"))))
(mac catcherr body
`(on-err idfn (fn () ,@body)))
(def makeerr (msg)
(catcherr (err msg)))
(mac testis (expr expected)
`(test-iso (tostring (write ',expr)) (catcherr ,expr) ,expected))
(mac cleandir (var dir . body)
`(let ,var ,dir
(system (+ "rm -rf " ,var))
(system (+ "mkdir " ,var))
,@body))
(mac w/testdir body
`(cleandir testdir (+ "/tmp/" (uniq))
,@body))
(mac w/foofile body
`(w/testdir (let foofile (+ testdir "/foo") ,@body)))