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
;;; Copyright (c) 2026 Nicholas Vermeulen
;;; SPDX-License-Identifier: AGPL-3.0-or-later
;; testkit-test.lisp โ golden test for testkit.lisp. Deterministic:
;; benchmark timings are asserted sane, never printed.
(load "testkit.lisp")
(deftest arithmetic
(assert-eq (+ 1 2) 3)
(assert-close (sqrt 2) 1.41421356 0.0001))
(deftest lists-and-truth
(assert-eq (map (lambda (x) (* x x)) '(1 2 3)) '(1 4 9))
(assert-true (if '() #t #f)) ; () is true โ SPEC ยง3
(assert-false (= 1 2)))
(deftest raising
(assert-raises (lambda () (/ 1 0)))
(assert-raises (lambda () (error "boom"))))
(deftest deliberately-failing ; the runner must survive and report
(assert-eq (* 2 2) 5))
(deftest deliberately-erroring
(undefined-function 42))
(define all-green (test-run))
(print (list 'suite-green all-green)) ; #f โ two tests fail by design
;; a fresh registry runs clean
(test-reset!)
(deftest only-good (assert-eq 1 1))
(print (list 'clean-suite (test-run)))
;; benchmarking utilities return sane numbers (values never golden-printed)
(define med (bench-median (lambda () (foldl + 0 '(1 2 3 4 5))) 5))
(print (list 'bench-median-sane (and (number? med) (>= med 0))))
(print "TESTKIT TESTS DONE")