34 lines
871 B
Common Lisp
34 lines
871 B
Common Lisp
;;; cl-scopes/testing
|
|
|
|
;;;; simple testing library
|
|
|
|
(defpackage :scopes/testing
|
|
(:use :common-lisp)
|
|
(:export #:*test-suite*
|
|
#:test-suite #:deftest #:show-result
|
|
#:test #:==))
|
|
|
|
(in-package :scopes/testing)
|
|
|
|
(defvar *test-suite* nil)
|
|
|
|
(defclass test-suite ()
|
|
((name :reader name :initform "test" :initarg :name)
|
|
(result :accessor result :initform nil)))
|
|
|
|
(defun test-suite (&optional (name "test"))
|
|
(make-instance 'test-suite :name name))
|
|
|
|
(defun show-result ()
|
|
(format t "~a~%" (name *test-suite*) )
|
|
(dolist (res (result *test-suite*))
|
|
(let ((tst (reverse res)))
|
|
(format t "~a: ~a~%" (string-downcase (car tst)) (cdr tst)))))
|
|
|
|
(defun == (have wanted)
|
|
(push (equalp have wanted) (car (result *test-suite*))))
|
|
|
|
(defmacro deftest (name args &body body)
|
|
`(defun ,name ,args
|
|
(push '(,name) (result *test-suite*))
|
|
,@body))
|