summaryrefslogtreecommitdiff
path: root/res/stdtest.lisp
blob: b7553fa0d7263bab6e680444185644481b424f76 (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
(import :ntest)


(comment "Re-export ntest.test as test.test")
(def test.test ntest.test)
(export test.test)

(comment "Fail a test with a certain message. Returns a closure; needs to be invoked as ((test.fail \"Fail Message\"))")
(defun test.fail (message) (ntest.fail message))
(export test.fail)

(comment "Assert true or fail with message. Returns a closure")
(defun test.assert (cond message) (if cond noop (ntest.fail message)))
(export test.assert)

(comment "Assert that two arguments are equal. Returns a closure")
(defun test.assert-eq (actual expected)
  (test.assert
      (= actual expected)
      (stringify "Expected" expected "got" actual)))
(export test.assert-eq)

(comment "Assert that two number arguments are equal with some tolerance. Returns a closure")
(defun test.assert-eqd (actual expected tolerance) (seq
  (test.assert
      (lt (abs (- expected actual)) tolerance)
      (stringify "Expected" expected "got" actual "with a tolerance of" tolerance))))
(export test.assert-eqd)