UNSLISP/tests.scm

58 lines
1.9 KiB
Scheme
Raw Normal View History

;;; 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.
(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))))
(load "doubly-linked-list.scm")
(display "running doubly linked list tests")
(newline)
(if (run-tests %dl:tests)
(display "doubly linked list tests: passed")
(display "doubly linked list tests: failed"))
(newline)