From 449074d2345be8a6041c4c3706823a6e1a292574 Mon Sep 17 00:00:00 2001 From: tony Date: Thu, 29 May 2008 16:35:15 +0200 Subject: [PATCH] unittest cleanup. prevent name clashes lisp-stat -> lisp-stat-ut (unittest) . compiles. --- unittests-arrays.lisp | 70 +++++++++++++++++++++++++++----------------------- unittests-lstypes.lisp | 29 +++++++++------------ unittests-proto.lisp | 51 +++++++++++------------------------- unittests.lisp | 69 ++++++++++++++++--------------------------------- 4 files changed, 87 insertions(+), 132 deletions(-) diff --git a/unittests-arrays.lisp b/unittests-arrays.lisp index 1267988..0759278 100644 --- a/unittests-arrays.lisp +++ b/unittests-arrays.lisp @@ -19,48 +19,52 @@ :lisp-stat ;; basic tools :lisp-stat-unittests) ;; support (:shadowing-import-from :lisp-stat - slot-value call-method call-next-method ;; objects - expt + - * / ** mod rem abs 1+ 1- log exp sqrt sin cos tan ;; lsmath + ;; objects + slot-value call-method call-next-method + + ;; lsmath + expt + - * / ** mod rem abs 1+ 1- log exp sqrt sin cos tan asin acos atan sinh cosh tanh asinh acosh atanh float random truncate floor ceiling round minusp zerop plusp evenp oddp - < <= = /= >= > ;; complex - conjugate realpart imagpart phase + < <= = /= >= > min max logand logior logxor lognot ffloor fceiling - ftruncate fround signum cis) + ftruncate fround signum cis + + ;; complex + conjugate realpart imagpart phase + + ;; matlisp + fft transpose) + (:shadowing-import-from :matlisp + real ;; common-lisp + ) (:export run-lisp-stat-tests run-lisp-stat-test scoreboard)) + (in-package :lisp-stat-unittests-arrays) -;;; TESTS - -(defun run-lisp-stat-tests () - (run-tests :suite 'lisp-stat)) +;;; TEST for Arrays and Linear Algebra. -(defun run-lisp-stat-test (&rest x) - (run-test x)) +(deftestsuite lisp-stat-ut-array (lisp-stat-ut) ()) -(deftestsuite lisp-stat-array (lisp-stat) ()) - - - -(addtest (lisp-stat-array) cholesky-decomposition-1 +(addtest (lisp-stat-ut-array) cholesky-decomposition-1 (ensure-same (chol-decomp #2A((2 3 4) (1 2 4) (2 4 5))) (list #2A((1.7888543819998317 0.0 0.0) - (1.6770509831248424 0.11180339887498929 0.0) - (2.23606797749979 2.23606797749979 3.332000937312528e-8)) + (1.6770509831248424 0.11180339887498929 0.0) + (2.23606797749979 2.23606797749979 3.332000937312528e-8)) 5.000000000000003) :test 'almost=lists)) #| -(addtest (lisp-stat-array) cholesky-decomposition-2 +(addtest (lisp-stat-ut-array) cholesky-decomposition-2 (ensure-same (matlisp:chol))) |# -(addtest (lisp-stat-array) lu-decomposition +(addtest (lisp-stat-ut-array) lu-decomposition (ensure-same (lu-decomp #2A((2 3 4) (1 2 4) @@ -70,7 +74,7 @@ -1.0 NIL))) -(addtest (lisp-stat-array) lu-decomposition-2 +(addtest (lisp-stat-ut-array) lu-decomposition-2 (ensure-same (lu-decomp (make-real-matrix #2A((2 3 4) (1 2 4) @@ -82,14 +86,14 @@ -(addtest (lisp-stat-array) rcondest +(addtest (lisp-stat-ut-array) rcondest ;; (ensure-same (ensure-error ;; it barfs, FIXME!! (rcondest #2A((2 3 4) (1 2 4) (2 4 5))) 6.8157451e7 :test 'almost=)) -(addtest (lisp-stat-array) lu-solve +(addtest (lisp-stat-ut-array) lu-solve (ensure-same (lu-solve (lu-decomp @@ -97,14 +101,14 @@ #(2 3 4)) #(-2.333333333333333 1.3333333333333335 0.6666666666666666))) -(addtest (lisp-stat-array) inverse +(addtest (lisp-stat-ut-array) inverse (ensure-same (inverse #2A((2 3 4) (1 2 4) (2 4 5))) #2A((2.0 -0.33333333333333326 -1.3333333333333335) (-1.0 -0.6666666666666666 1.3333333333333333) (0.0 0.6666666666666666 -0.3333333333333333)))) -(addtest (lisp-stat-array) sv-decomp +(addtest (lisp-stat-ut-array) sv-decomp (ensure-same (sv-decomp #2A((2 3 4) (1 2 4) (2 4 5))) (list #2A((-0.5536537653489974 0.34181191712789266 -0.7593629708013371) @@ -117,7 +121,7 @@ T) :test 'almost=lists)) -(addtest (lisp-stat-array) qr-decomp +(addtest (lisp-stat-ut-array) qr-decomp (ensure-same (qr-decomp #2A((2 3 4) (1 2 4) (2 4 5))) (list #2A((-0.6666666666666665 0.7453559924999298 5.551115123125783e-17) @@ -128,7 +132,7 @@ (0.0 0.0 -1.3416407864998738))) :test 'almost=lists)) -(addtest (lisp-stat-array) eigen +(addtest (lisp-stat-ut-array) eigen (ensure-same (eigen #2A((2 3 4) (1 2 4) (2 4 5))) (list #(10.656854249492381 -0.6568542494923802 -0.9999999999999996) @@ -137,7 +141,7 @@ #(0.7071067811865483 -0.7071067811865466 -1.2560739669470215e-15)) NIL))) -(addtest (lisp-stat-array) spline +(addtest (lisp-stat-ut-array) spline (ensure-same (spline #(1.0 1.2 1.3 1.8 2.1 2.5) #(1.2 2.0 2.1 2.0 1.1 2.8) @@ -146,7 +150,7 @@ (list 1.2 2.1 2.2750696543866313 1.6465231041904045 1.2186576148879609 2.8)) :test 'almost=lists)) -(addtest (lisp-stat-array) kernel-smooth +(addtest (lisp-stat-ut-array) kernel-smooth (ensure-same ;; using KERNEL-SMOOTH-FRONT, not KERNEL-SMOOTH-CPORT (kernel-smooth @@ -158,7 +162,7 @@ 1.5871511322219498 2.518194783156392)) :test 'almost=lists)) -(addtest (lisp-stat-array) kernel-dens +(addtest (lisp-stat-ut-array) kernel-dens (ensure-same (kernel-dens #(1.0 1.2 2.5 2.1 1.8 1.2) @@ -168,17 +172,19 @@ 0.4829822708587095 0.3485939156929503)))) -(addtest (lisp-stat-array) fft +(addtest (lisp-stat-ut-array) fft (ensure-same (fft #(1.0 1.2 2.5 2.1 1.8)) (list #(#C(1.0 0.0) #C(1.2 0.0) #C(2.5 0.0) #C(2.1 0.0) #C(1.8 0.0))) :test 'almost=lists)) -(addtest (lisp-stat-array) lowess +(addtest (lisp-stat-ut-array) lowess (ensure-same (lowess #(1.0 1.2 2.5 2.1 1.8 1.2) #(1.2 2.0 2.1 2.0 1.1 2.8)) #(1.0 1.2 1.2 1.8 2.1 2.5) :test 'almost=lists)) ;; result isn't a list! +;; (run-tests :suite 'lisp-stat-ut-array) + diff --git a/unittests-lstypes.lisp b/unittests-lstypes.lisp index f4f3acd..a31f3e8 100644 --- a/unittests-lstypes.lisp +++ b/unittests-lstypes.lisp @@ -5,7 +5,7 @@ ;;; Copyright: (c)2008, AJ Rossini. ;;; License: BSD, see LICENSE.BSD file for details. ;;; Purpose: unit-tests for lispstat typing. -;;; Time-stamp: <2008-05-09 14:16:56 tony> +;;; Time-stamp: <2008-05-28 08:25:28 tony> ;;; Creation: <2008-05-09 14:16:56 tony> ;;; What is this talk of 'release'? Klingons do not make software @@ -27,20 +27,15 @@ (in-package :lisp-stat-types-unittests) -(defun run-lisp-stat-tests () - (run-tests :suite 'lisp-stat)) -(defun run-lisp-stat-test (&rest x) - (run-test x)) +(deftestsuite lisp-stat-ut-types (lisp-stat-ut) ()) -(deftestsuite lisp-stat-types (lisp-stat) ()) - -(addtest (lisp-stat-types) check-one-nonneg-fixnum1 +(addtest (lisp-stat-ut-types) check-one-nonneg-fixnum1 (ensure-error ;; (check-one-nonneg-fixnum -3) => error (check-one-nonneg-fixnum -3))) -(addtest (lisp-stat-types) check-one-nonneg-fixnum2 +(addtest (lisp-stat-ut-types) check-one-nonneg-fixnum2 (ensure ;; (check-one-nonneg-fixnum 3) => 3 (= 3 @@ -50,13 +45,13 @@ ;;; check-one-nonneg-fixnum -(addtest (lisp-stat-types) check-nonneg-fixnum1 +(addtest (lisp-stat-ut-types) check-nonneg-fixnum1 (ensure ;; (check-one-nonneg-fixnum 3) => 3 (= 3 (check-nonneg-fixnum 3)))) -(addtest (lisp-stat-types) check-nonneg-fixnum2 +(addtest (lisp-stat-ut-types) check-nonneg-fixnum2 (ensure ;; (check-one-nonneg-fixnum 3) => 3 (equal (list 1 2 3) @@ -64,24 +59,24 @@ ;;; check-nonneg-fixnum -(addtest (lisp-stat-types) check-nonneg-fixnum1 +(addtest (lisp-stat-ut-types) check-nonneg-fixnum1 (ensure (= 3 (check-nonneg-fixnum 3)))) -(addtest (lisp-stat-types) check-nonneg-fixnum2 +(addtest (lisp-stat-ut-types) check-nonneg-fixnum2 (ensure (equal (list 1 2 3) (check-nonneg-fixnum (list 1 2 3))))) -(addtest (lisp-stat-types) check-nonneg-fixnum3 +(addtest (lisp-stat-ut-types) check-nonneg-fixnum3 (ensure-error (check-nonneg-fixnum -3))) -(addtest (lisp-stat-types) check-nonneg-fixnum4 +(addtest (lisp-stat-ut-types) check-nonneg-fixnum4 (ensure-error (check-nonneg-fixnum (list 1 2 -3)))) ;;; -;; (run-tests) -;; (describe (run-tests)) +;; (run-tests :suite 'lisp-stat-ut-lstypes) +;; (describe (run-tests :suite 'lisp-stat-ut-lstypes)) diff --git a/unittests-proto.lisp b/unittests-proto.lisp index 9d094b3..353cc38 100644 --- a/unittests-proto.lisp +++ b/unittests-proto.lisp @@ -10,8 +10,8 @@ (in-package :cl-user) -(defpackage :lisp-stat-unittests - (:use :common-lisp :lift :lisp-stat) +(defpackage :lisp-stat-unittests-proto + (:use :common-lisp :lift :lisp-stat :lisp-stat-unittests) (:shadowing-import-from :lisp-stat slot-value call-method call-next-method ;; objects expt + - * / ** mod rem abs 1+ 1- log exp sqrt sin cos tan ;; lsmath @@ -21,44 +21,23 @@ conjugate realpart imagpart phase min max logand logior logxor lognot ffloor fceiling ftruncate fround signum cis) - (:export run-lisp-stat-tests run-lisp-stat-test scoreboard ; exec - almost= almost=lists numerical=)) ; compare + (:export lisp-stat-ut-proto)) ;; unit tests -- rename? -(in-package :lisp-stat-unittests) +(in-package :lisp-stat-unittests-proto) -;;; TESTS - -(defun run-lisp-stat-tests () - (run-tests :suite 'lisp-stat)) - -(defun run-lisp-stat-test (&rest x) - (run-test x)) +;;; Object System tests (deftestsuite lisp-stat-proto (lisp-stat) ()) -;;;; Object System tests - -;;(deftestsuite lisp-stat-proto-objects (lisp-stat) -;; () -;; (:documentation "Make sure the proto object system is valid.") -;; (:tests -;; (create-proto (ensure (object-proto-p (defproto test-me)))) -;; (create-proto2 (ensure (object-proto-p (defproto2 test-me2)))) -;; (instance1 (ensure (send test-me :isnew))) -;; (instance1-2 (ensure (send test-me2 :isnew))) -;; (instance2 (ensure (send test-me :has-slot 'new))) -;; (instance2-2 (ensure (send test-me2 :has-slot 'new))) - -;; (instance5 (ensure (send test-me :has-slot 'new))) -;; (instance5-2 (ensure (send test-me2 :has-slot 'new))) -;; (instance5 (ensure (send test-me :own-slots 'new))) -;; (instance5-2 (ensure (send test-me2 :own-slots 'new))) -;; (instance5 (ensure (send test-me :has-slot 'new))) -;; (instance5-2 (ensure (send test-me2 :has-slot 'new))) -;; (instance5 (ensure (send test-me :has-slot 'new))) -;; (instance5-2 (ensure (send test-me2 :has-slot 'new))) - -;; )) +;; need to ensure stability of add, display, send, instantiate and +;; similar actions. +(deftestsuite lisp-stat-ut-proto (lisp-stat) + () + (:tests + (create-proto (ensure (typep (defproto test-me) 'instance))) + (instance1 (ensure (send test-me :isnew))) + (instance2 (ensure (send test-me :has-slot 'new))) + (instance5 (ensure (send test-me :own-slots 'new))))) - \ No newline at end of file +;; (run-tests :suite 'lisp-stat-ut-proto) diff --git a/unittests.lisp b/unittests.lisp index 3c404b1..c7c65bd 100644 --- a/unittests.lisp +++ b/unittests.lisp @@ -35,10 +35,10 @@ (run-test x)) -(deftestsuite lisp-stat () ()) -(deftestsuite lisp-stat-lin-alg (lisp-stat) ()) -(deftestsuite lisp-stat-spec-fns (lisp-stat) ()) -(deftestsuite lisp-stat-probdistn (lisp-stat) ()) +(deftestsuite lisp-stat-ut () ()) +(deftestsuite lisp-stat-ut-lin-alg (lisp-stat-ut) ()) +(deftestsuite lisp-stat-ut-spec-fns (lisp-stat-ut) ()) +(deftestsuite lisp-stat-ut-probdistn (lisp-stat-ut) ()) (defun almost= (a b &key (tol 0.000001)) @@ -103,7 +103,7 @@ :tol tol)))) (every #'(lambda (x) x) a-b-elt-eq)))) -(deftestsuite lisp-stat-testsupport (lisp-stat) +(deftestsuite lisp-stat-ut-testsupport (lisp-stat-ut) () (:tests (almost=1 (ensure (almost= 3 3.001 :tol 0.01))) @@ -116,7 +116,7 @@ (almost=lists5 (ensure (not (almost=lists (list 1.0 1.0) (list 1.0 1.1) :tol 0.01)))))) -(deftestsuite lisp-stat-testsupport2 (lisp-stat) +(deftestsuite lisp-stat-ut-testsupport2 (lisp-stat-ut) () (:tests (numerical=1 (ensure (numerical= 3 3.001 :tol 0.01))) @@ -156,13 +156,13 @@ )) -;; (describe (run-tests :suite 'lisp-stat-testsupport2)) +;; (describe (run-tests :suite 'lisp-stat-ut-testsupport2)) ;;;; Log-gamma function -(addtest (lisp-stat-spec-fns) log-gamma-fn +(addtest (lisp-stat-ut-spec-fns) log-gamma-fn (ensure-same (log-gamma 3.4) 1.0923280596789584 @@ -177,23 +177,23 @@ ;; cdf-params cdf-answer ;; pmf-params pmf-answer ;; rand-params rand-answer) -;; (deftestsuite lisp-stat-probdist-,prefixName (lisp-stat-probdistn) +;; (deftestsuite lisp-stat-ut-probdist-,prefixName (lisp-stat-ut-probdistn) ;; ;; (( )) ;; (:documentation "testing for ,testName distribution results") ;; (:test (ensure-same -;; (lisp-stat-basics:,testName-quant ,quant-params) ,quant-answer)) +;; (lisp-stat-ut-basics:,testName-quant ,quant-params) ,quant-answer)) ;; (:test (ensure-same -;; (lisp-stat-basics:,testName-cdf ,cdf-params) ,cdf-answer)) +;; (lisp-stat-ut-basics:,testName-cdf ,cdf-params) ,cdf-answer)) ;; (:test (ensure-same -;; (lisp-stat-basics:,testName-pmf ,pmf-params) ,pmf-answer)) +;; (lisp-stat-ut-basics:,testName-pmf ,pmf-params) ,pmf-answer)) ;; (:test (progn ;; (set-seed 234) ;; (ensure-same -;; (lisp-stat-basics:,testName-rand ,rand-params) ,rand-answer))))) +;; (lisp-stat-ut-basics:,testName-rand ,rand-params) ,rand-answer))))) ;;; Normal distribution -(deftestsuite lisp-stat-probdist-f (lisp-stat-probdistn) +(deftestsuite lisp-stat-ut-probdist-f (lisp-stat-ut-probdistn) () (:documentation "testing for Gaussian distn results") (:test (ensure-same @@ -214,7 +214,7 @@ ;;;; Cauchy distribution -(deftestsuite lisp-stat-probdist-cauchy (lisp-stat-probdistn) +(deftestsuite lisp-stat-ut-probdist-cauchy (lisp-stat-ut-probdistn) () (:documentation "testing for Cachy-distn results") (:test (ensure-same @@ -232,7 +232,7 @@ ;;;; Gamma distribution -(deftestsuite lisp-stat-probdist-gamma (lisp-stat-probdistn) +(deftestsuite lisp-stat-ut-probdist-gamma (lisp-stat-ut-probdistn) () (:documentation "testing for gamma distn results") (:test (ensure-same @@ -250,7 +250,7 @@ ;;;; Chi-square distribution -(deftestsuite lisp-stat-probdist-chisq (lisp-stat-probdistn) +(deftestsuite lisp-stat-ut-probdist-chisq (lisp-stat-ut-probdistn) () (:documentation "testing for Chi-square distn results") (:test (ensure-same @@ -270,7 +270,7 @@ ;;;; Beta distribution -(deftestsuite lisp-stat-probdist-beta (lisp-stat-probdistn) +(deftestsuite lisp-stat-ut-probdist-beta (lisp-stat-ut-probdistn) () (:documentation "testing for beta distn results") (:test (ensure-same @@ -288,7 +288,7 @@ ;;;; t distribution -(deftestsuite lisp-stat-probdist-t (lisp-stat-probdistn) +(deftestsuite lisp-stat-ut-probdist-t (lisp-stat-ut-probdistn) () (:documentation "testing for t-distn results") (:test (ensure-same @@ -306,7 +306,7 @@ ;;;; F distribution -(deftestsuite lisp-stat-probdist-f (lisp-stat-probdistn) +(deftestsuite lisp-stat-ut-probdist-f (lisp-stat-ut-probdistn) () (:documentation "testing for f-distn results") (:test (ensure-same @@ -325,7 +325,7 @@ ;;;; Poisson distribution -(deftestsuite lisp-stat-probdist-poisson (lisp-stat-probdistn) +(deftestsuite lisp-stat-ut-probdist-poisson (lisp-stat-ut-probdistn) () (:documentation "testing for poisson distribution results") (:test (ensure-same @@ -344,7 +344,7 @@ ;; Binomial distribution -(deftestsuite lisp-stat-probdist-binomial (lisp-stat-probdistn) +(deftestsuite lisp-stat-ut-probdist-binomial (lisp-stat-ut-probdistn) () (:documentation "testing for binomial distribution results") @@ -370,29 +370,4 @@ -;;;; Object System tests - -;;(deftestsuite lisp-stat-proto-objects (lisp-stat) -;; () -;; (:documentation "Make sure the proto object system is valid.") -;; (:tests -;; (create-proto (ensure (object-proto-p (defproto test-me)))) -;; (create-proto2 (ensure (object-proto-p (defproto2 test-me2)))) -;; (instance1 (ensure (send test-me :isnew))) -;; (instance1-2 (ensure (send test-me2 :isnew))) -;; (instance2 (ensure (send test-me :has-slot 'new))) -;; (instance2-2 (ensure (send test-me2 :has-slot 'new))) - -;; (instance5 (ensure (send test-me :has-slot 'new))) -;; (instance5-2 (ensure (send test-me2 :has-slot 'new))) -;; (instance5 (ensure (send test-me :own-slots 'new))) -;; (instance5-2 (ensure (send test-me2 :own-slots 'new))) -;; (instance5 (ensure (send test-me :has-slot 'new))) -;; (instance5-2 (ensure (send test-me2 :has-slot 'new))) -;; (instance5 (ensure (send test-me :has-slot 'new))) -;; (instance5-2 (ensure (send test-me2 :has-slot 'new))) - -;; )) - - \ No newline at end of file -- 2.11.4.GIT