blob: ae9323758e5d9426e8f28ea1e5a18017575e8e83 (
plain) (
blame)
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
|
;;; Copyright (C) Peter McGoron 2024
;;; This program is free software: you can redistribute it and/or modify
;;; it under the terms of the GNU General Public License as published by
;;; the Free Software Foundation, version 3 of the License.
;;;
;;; This program is distributed in the hope that it will be useful,
;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;;; GNU General Public License for more details.
;;;
;;; You should have received a copy of the GNU General Public License
;;; along with this program. If not, see <https://www.gnu.org/licenses/>.
;;; Test harness.
;;; Each test is a name and a function with no arguments. The function
;;; returns #t for success, #f for undefined failure, and a string for
;;; known failure.
;;;
;;; TODO: Return test results as a list.
(load "util.scm")
(define verbose? #t)
(define run-tests
(lambda (tests)
(letrec
((run-test
(lambda (name test)
(if verbose?
(begin
(display "running: ")
(display name)
(newline))
#f)
(let ((result (test)))
(if (not result)
"undefined failure"
result))))
(loop
(lambda (rest)
(if (null? rest)
#t
(let ((descr (car rest)))
(let ((return (run-test
(car descr)
(cdr descr))))
(if (not (eq? return #t))
return
(loop (cdr rest)))))))))
(loop tests))))
(define report-tests
(lambda (tests)
(let ((res (run-tests tests)))
(if (eq? res #t)
(display "passed")
(begin
(display "failed: ")
(display res))))
(newline)))
(load "doubly-linked-list.scm")
(display "running doubly linked list tests: ")
(newline)
(report-tests %dl:tests)
(load "set.scm")
(display "running string BST-AVL tests")
(newline)
(report-tests %set:tests)
(load "trie.scm")
(display "char trie")
(newline)
(report-tests %trie:tests)
|