-
Notifications
You must be signed in to change notification settings - Fork 4
/
self-test.lisp
executable file
·76 lines (66 loc) · 2.19 KB
/
self-test.lisp
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
69
70
71
72
73
74
75
76
;;;;; SHOULD-TEST self-test suite
;;;;; (c) 2013 Vsevolod Dyomkin
(in-package #:should-test)
(named-readtables:in-readtable rutils-readtable)
(defmethod asdf:perform ((o asdf:test-op)
(s (eql (asdf:find-system :should-test))))
(asdf:load-system :should-test)
(let ((*verbose* nil))
(test :package :should-test))
t)
(deftest deftest ()
(should be true
(progn (deftest foo ())
(get 'foo 'test)))
(should be null
(progn (deftest foo ())
(get 'foo 'test))))
(deftest undeftest ()
(should be true
(progn (deftest foo0 ())
(undeftest 'foo0)))
(should be null
(undeftest 'foo0)))
(deftest test ()
(should signal should-test-error
(let ((*test-output* (make-broadcast-stream)))
(test :test (gensym))))
(should be true
(let ((*test-output* (make-broadcast-stream)))
(test :test 'deftest)))
(should be true
(test :package :cl)) ;; no tests defined for CL package
(should be null
(handler-case (unwind-protect
(let ((*test-output* (make-broadcast-stream)))
(deftest foo1 () (should be null t))
(test :test 'foo1))
(undeftest 'foo1))
(should-failed ())))
(should be true
(let ((*test-output* (make-broadcast-stream)))
(deftest foo2 ()
(let ((bar t))
(+ 1 2)
(should be true bar)))
(prog1 (test :test 'foo2)
(undeftest 'foo2)))))
(deftest should-be ()
(let ((*test-output* (make-broadcast-stream)))
(should be null
(handler-case (should be eql nil t)
(should-checked () nil)))))
(deftest should-signal ()
(let ((*test-output* (make-broadcast-stream)))
(should signal simple-error
(error "Error"))))
(deftest should-print-to ()
(let ((*verbose* t))
(should print-to *test-output*
"(PRINC bar) FAIL
expect: \"foo\"
actual: \"bar\"
"
(handler-case
(should print-to *standard-output* "foo" (princ "bar"))
(should-checked () nil)))))