;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -*- Mode: Lisp -*- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; File - tests.lisp
;; Description - Example tests
;; Author - Gail Anderson (ga at lostwithiel)
;; Created On - Fri Feb 25 17:28:09 2000
;; Last Modified On - Mon Jul 9 09:41:01 2001
;; Last Modified By - Gail Anderson (ga at lostwithiel)
;; Update Count - 18
;; Status - Unknown
;;
;; $Id: tests.lisp,v 1.1 2003/01/09 02:11:35 colin Exp $
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(in-package :solution-tests)
;;; Sample test for hello-world
(defun test-hello-world (score &key (stream t))
;; enter in as many of these tests as you like
(unless
(test-call
1
(exercise:hello-world)
nil
"to see whether it returns nil as defined"
:test #'eq
:stream stream)
(decf score))
;; the function should finally return the score for the tests
;; it carries out
score)
(push
;; the function to be tested, the test function, total possible
;; score, if appropriate the name of a library (fasl) file in which
;; is kept a working version of the code, minus this function, so
;; that each function can be tested independently
`(hello-world ,#'test-hello-world 1 nil
"Check that the hello world output appears.")
*test-detail-list*)
;;; Sample tests for add2
(defun test-add2 (score &key (stream t))
;; enter in as many of these tests as you like
(unless
(test-call
1 ; number of this test
(exercise:add2 0) ; the form to evaluate
2 ; expected result
"to see whether it works on 0 as a boundary case" ; comment to
; print for students
:test #'= ; test to use to compare expected
; and actual result
:stream stream) ; stream to print output to
(decf score))
(unless
(test-call
2
(exercise:add2 2)
4
"to test it on a positive integer"
:test #'=
:stream stream))
;; the function should finally return the score for the tests
;; it carries out
score)
(push
`(add2 ,#'test-add2 2 nil
"None.")
*test-detail-list*)