3 ;;; Time-stamp: <2009-10-30 08:01:50 tony>
4 ;;; Creation: <2009-10-30 07:52:31 tony>
5 ;;; File: unittests-data.lisp
6 ;;; Author: AJ Rossini <blindglobe@gmail.com>
7 ;;; Copyright: (c)2008--, AJ Rossini. This instance licensed under
8 ;;; the MIT license. See file LICENSE.mit in top-level
9 ;;; directory for information.
10 ;;; Purpose: unittests for abstract data
12 ;;; What is this talk of 'release'? Klingons do not make software
13 ;;; 'releases'. Our software 'escapes', leaving a bloody trail of
14 ;;; designers and quality assurance people in its wake.
16 (in-package :lisp-stat-unittests
)
18 (deftestsuite lisp-stat-ut-data
(lisp-stat-ut)
20 (make-instance 'empirical-statistical-variable
23 (make-instance 'modelbased-statistical-variable
24 :pdmf
#'(lambda (x) 1.0d0
)
27 ;;; Ensure helper-functions work
29 (addtest (lisp-stat-ut-data) emp-stat-var-class
31 (equal (nobs my-statvar-emp-1
)
34 (describe (run-test :name
'emp-stat-var-class
:suite
'lisp-stat-ut-data
))
36 (addtest (lisp-stat-ut-dataframe) repeatseq
38 (equal (cls-dataframe::repeat-seq
3 "d")
41 (equal (cls-dataframe::repeat-seq
3 'd
)
45 (addtest (lisp-stat-ut-dataframe) make-labels
47 (equal (cls-dataframe::make-labels
"c" 3)
48 (list "c1" "c2" "c3")))
50 (cls-dataframe::make-labels
'c
3)))
55 (addtest (lisp-stat-ut-dataframe) df-equalp
57 (equalp (dataset (make-instance 'dataframe-array
63 (addtest (lisp-stat-ut-dataframe) df-consdata
65 (consistent-dataframe-p my-df-1
)))
67 (addtest (lisp-stat-ut-dataframe) df-consdata
69 (slot-value my-df-1
'store
)))
71 (addtest (lisp-stat-ut-dataframe) df-consdata
73 (slot-value my-df-1
'cls-dataframe
::store
)))
75 (addtest (lisp-stat-ut-dataframe) df-consdata
79 (addtest (lisp-stat-ut-dataframe) df-consdata
82 (slot-value my-df-1
'cls-dataframe
::store
)
83 (cls-dataframe::dataset my-df-1
))))
85 (addtest (lisp-stat-ut-dataframe) df-consdata
87 (eq (cls-dataframe::dataset my-df-1
)
88 (slot-value my-df-1
'cls-dataframe
::store
))))
90 ;; NEVER REACH INTO CLASS INTERIORS, NO PROMISE
91 ;; GUARANTEE OF LATER CONSISTENCY...
93 (addtest (lisp-stat-ut-dataframe) df-consdata
95 (cls-dataframe::doc-string my-df-1
))
97 (doc-string my-df-1
)))
99 (addtest (lisp-stat-ut-dataframe) df-consdata
101 (cls-dataframe::case-labels my-df-1
))
103 (case-labels my-df-1
)))
105 (addtest (lisp-stat-ut-dataframe) df-consdata
107 (cls-dataframe::var-labels my-df-1
))
109 (var-labels my-df-1
)))
111 ;; need to ensure that for things like the following, that we protect
112 ;; this a bit more so that the results are not going to to be wrong.
113 ;; That would be a bit nasty if the dataframe-array becomes
116 (addtest (lisp-stat-ut-dataframe) badAccess9
118 (setf (cls-dataframe::var-labels my-df-1
)
121 (addtest (lisp-stat-ut-dataframe) badAccess10
124 ;; no error, but corrupts structure
125 (setf (cls-dataframe::var-labels my-df-1
)
127 ;; error happens here
128 (not (consistent-dataframe-p my-df-1
))))) ;; Nil
130 (addtest (lisp-stat-ut-dataframe) badAccess12
132 (setf (cls-dataframe::var-labels my-df-1
)
135 (addtest (lisp-stat-ut-dataframe) badAccess13
137 (consistent-dataframe-p my-df-1
))) ;; T
139 ;; This is now done by:
140 (addtest (lisp-stat-ut-dataframe) badAccess14
142 (let ((old-varnames (varNames my-df-1
)))
143 (setf (varNames my-df-1
) (list "a" "b")) ;; should error
144 (setf (varNames my-df-1
) old-varnames
)
145 (error "don't reach this point in badaccess14"))))
148 ;; NEED TO CONFIRM THERE IS AN ERROR.
149 (addtest (lisp-stat-ut-dataframe) badAccess15
151 (let ((origCaseNames (caselabels my-df-1
)))
152 (setf (caselabels my-df-1
) (list "a" "b" "c" 4 5))
155 (setf (caselabels my-df-1
)
157 (setf (caselabels my-df-1
) origCaseNames
))))
161 ;; (describe (run-tests))
166 (make-instance 'dataframe-array
173 (make-instance 'dataframe-array
180 (make-instance 'dataframe-array
181 :storage
#2A
((1d0 2d0
)