;;; -*- Mode: Lisp -*- ;;; ;;; $Header: /home/gene/library/website/docsrc/lht/RCS/perf.lisp,v 1.1 2004/01/28 01:15:51 gene Exp gene $ ;;; ;;; Copyright (C) 2004 Gene Michael Stover ;;; ;;; This library is free software; you can redistribute it ;;; and/or modify it under the terms of version 2.1 of the GNU ;;; Lesser General Public License as published by the Free ;;; Software Foundation. ;;; ;;; This library 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 Lesser General Public License for more ;;; details. ;;; ;;; You should have received a copy of the GNU Lesser General ;;; Public License along with this library; if not, write to the ;;; Free Software Foundation, Inc., 59 Temple Place, Suite 330, ;;; Boston, MA 02111-1307 USA ;;; (defvar *is-verbose* nil) (defvar *tests* nil "List of all the tests. For the most useful error messages when a test fails, each element should be a symbol bound to a test function, not the function itself.") (setq *tests* nil) (defmacro deftest (name &rest args-doc-body) `(progn (setq *tests* (append *tests* (list ',name))) (defun ,name ,@args-doc-body))) (defun check (lst) "Executes all the tests in LST until they all execute or one of them fails." (labels ((call-test (fn i) (when *is-verbose* (format t "~&try ~D, ~A" i fn)) (if (funcall fn) t (progn (format t "~&*** test number ~D, ~A, failed ***" i fn) nil)))) (do ((x lst (rest x)) (i 0 (1+ i)) (result t (call-test (car x) i))) ((or (endp x) (null result)) result)))) (deftest test0000 () "Null test. Always succeeds." t) (deftest test0001 () "Test slurp-stream-simple on a hard-coded, multi-line string input." (let* ((input (format nil "one~%two~%")) (output (with-input-from-string (strm input) (slurp-stream-simple strm))) (is-good (equal input output))) (unless is-good (format t "~&input string is ~S" input) (format t "~&output string is ~S" output)) is-good)) (deftest test0003 () "Test slurp-stream-faster on a hard-coded, multi-line string input." (let* ((input (format nil "one~%two~%")) (output (with-input-from-string (strm input) (slurp-stream-faster strm))) (is-good (equal input output))) (unless is-good (format t "~&input string is ~S" input) (format t "~&output string is ~S" output)) is-good)) (deftest test0010 () "Test convert-template on a short hard-coded HTML template that contains no Lisp." (let* ((input "") (output (convert-template input)) (expected '(progn (princ "" strm))) (is-good (equal output expected))) (unless is-good (format t "~&input is ~S" input) (format t "~&output is ~S" output) (format t "~&expected is ~S" expected)) is-good)) ;;;--- end of file ---