;;; ;;; Time-stamp: <06/03/11 12:14:53 noel> ;;; ;;; Copyright (C) 2005 by Noel Welsh. ;;; ;;; This library is free software; you can redistribute it ;;; and/or modify it under the terms of the GNU Lesser ;;; General Public License as published by the Free Software ;;; Foundation; either version 2.1 of the License, or (at ;;; your option) any later version. ;;; 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 ;;; Author: Noel Welsh <noelwelsh@yahoo.com> ;; ;; ;; Commentary: ;; The tests below are intended as examples of how to use ;; the test package. They test PLT Scheme's arithmetic ;; operations and some simple file reading (require (file "test.ss")) (require (file "text-ui.ss")) (test/text-ui (test-suite "Example tests" (test-suite "Arithmetic tests" (test-check "Multiply by zero" = (* 1234 0) 0) (test-check "Add zero" = (+ 1234 0) 1234) (test-check "Multiply by one" = (* 123.0 1) 123) (test-check "Add one" = (+ 123.0 1) 124) (test-check "Expt 0 0" = 1 (expt 0 0)) (test-check "Expt 0 1" = 0 (expt 0 1)) (test-check "Expt 0.0 0.0" = 1.0 (expt 0.0 0.0)) (test-check "Expt 0.0 1.0" = 0.0 (expt 0.0 1.0)) ) (test-suite "File tests" ;; An example with an after action (test-case "String port read" (let ((port (open-input-string "this is a test string"))) (after (check-equal? "this is a test string" (read-line port)) ((close-input-port port))))) ;; An example with an around action (test-case "File port read" (around ((with-output-to-file "test.dat" (lambda () (write "foo")))) (with-input-from-file "test.dat" (lambda () (check-equal? "foo" (read)))) ((delete-file "test.dat")))) ) ))