From 6b21da53de3f255587fc17a48d5d005a53f3d393 Mon Sep 17 00:00:00 2001 From: AJ Rossini Date: Wed, 1 Apr 2009 08:25:04 +0200 Subject: [PATCH] unittesting for dataframes cleaned up, thanks to reading the documentation. Tests are almost current with described functionality. Signed-off-by: AJ Rossini --- TODO.lisp | 4 +- src/unittests/unittests-data-clos.lisp | 145 +++++++++++++++------------------ 2 files changed, 66 insertions(+), 83 deletions(-) diff --git a/TODO.lisp b/TODO.lisp index 59e38cf..9491f63 100644 --- a/TODO.lisp +++ b/TODO.lisp @@ -1,6 +1,6 @@ ;;; -*- mode: lisp -*- -;;; Time-stamp: <2009-03-31 17:05:06 tony> +;;; Time-stamp: <2009-04-01 08:16:19 tony> ;;; Creation: <2008-09-08 08:06:30 tony> ;;; File: TODO.lisp ;;; Author: AJ Rossini @@ -22,7 +22,7 @@ (in-package :lisp-stat-unittests) -;; tests = 87, failures = 8, errors = 21 +;; tests = 80, failures = 7, errors = 17 (describe (run-tests :suite 'lisp-stat-ut)) (run-tests :suite 'lisp-stat-ut) diff --git a/src/unittests/unittests-data-clos.lisp b/src/unittests/unittests-data-clos.lisp index 9ffa32d..f51238f 100644 --- a/src/unittests/unittests-data-clos.lisp +++ b/src/unittests/unittests-data-clos.lisp @@ -5,7 +5,7 @@ ;;; Copyright: (c)2008, AJ Rossini. BSD, LLGPL, or GPLv2, depending ;;; on how it arrives. ;;; Purpose: unittests for the data-clos package -;;; Time-stamp: <2009-03-31 08:30:13 tony> +;;; Time-stamp: <2009-04-01 07:59:08 tony> ;;; Creation: <2008-05-09 14:18:19 tony> ;;; What is this talk of 'release'? Klingons do not make software @@ -14,7 +14,21 @@ (in-package :lisp-stat-unittests) -(deftestsuite lisp-stat-ut-dataclos (lisp-stat-ut) ()) +(deftestsuite lisp-stat-ut-dataclos (lisp-stat-ut) + ((my-df-1 + (make-instance 'dataframe-array + :storage #2A((1 2 3 4 5) + (10 20 30 40 50)) + :doc "This is an interesting legal dataframe-array" + :case-labels (list "x" "y") + :var-labels (list "a" "b" "c" "d" "e"))) + (my-df-0 + (make-instance 'dataframe-array + :storage #2A((1 2 3 4 5) + (10 20 30 40 50)) + :doc "This is an interesting illegal dataframe-array" + :case-labels (list "a" "b" "c" "d" "e") + :var-labels (list "x" "y"))))) ;;; Ensure helper-functions work @@ -43,15 +57,7 @@ (list 'd 'd 'd)))) - - - - - - - - -;;; Dataframe +;;; Dataframe tests (addtest (lisp-stat-ut-dataclos) df-equalp (ensure @@ -61,72 +67,53 @@ #2A(('a 'b) ('c 'd))))) - -;; FAKE DF -(defparameter *my-df-0* - (make-instance 'dataframe-array - :storage #2A((1 2 3 4 5) - (10 20 30 40 50)) - :doc "This is an interesting dataframe-array" - :case-labels (list "a" "b" "c" "d" "e") - :var-labels (list "x" "y"))) - -;; WORKING DF -(defparameter *my-df-1* - (make-instance 'dataframe-array - :storage #2A((1 2 3 4 5) - (10 20 30 40 50)) - :doc "This is an interesting dataframe-array" - :case-labels (list "x" "y") - :var-labels (list "a" "b" "c" "d" "e"))) - (addtest (lisp-stat-ut-dataclos) df-consdata - (ensure - (consistent-dataframe-p *my-df-1*))) + (ensure + (consistent-dataframe-p my-df-1))) -(addtest (lisp-stat-ut-dataclos) df-access-1 +(addtest (lisp-stat-ut-dataclos) df-consdata (ensure-error - (slot-value *my-df-1* 'store))) + (slot-value my-df-1 'store))) -(addtest (lisp-stat-ut-dataclos) df-access-2 - (ensure-error - (slot-value *my-df-1* 'store))) +(addtest (lisp-stat-ut-dataclos) df-consdata + (ensure + (slot-value my-df-1 'lisp-stat-data-clos::store))) -(addtest (lisp-stat-ut-dataclos) df-access-3 +(addtest (lisp-stat-ut-dataclos) df-consdata (ensure - (dataset *my-df-1*))) + (dataset my-df-1))) -(addtest (lisp-stat-ut-dataclos) df-access-4 +(addtest (lisp-stat-ut-dataclos) df-consdata (ensure (equalp - (slot-value *my-df-1* 'lisp-stat-data-clos::store) - (lisp-stat-data-clos::dataset *my-df-1*)))) + (slot-value my-df-1 'lisp-stat-data-clos::store) + (lisp-stat-data-clos::dataset my-df-1)))) -(addtest (lisp-stat-ut-dataclos) badAccess5 +(addtest (lisp-stat-ut-dataclos) df-consdata (ensure - (eq (lisp-stat-data-clos::dataset *my-df-1*) - (slot-value *my-df-1* 'lisp-stat-data-clos::store)))) - + (eq (lisp-stat-data-clos::dataset my-df-1) + (slot-value my-df-1 'lisp-stat-data-clos::store)))) -;; NEVER REACH INTO CLASS INTERIORS, NO PROMISE GUARANTEE OF LATER CONSISTENCY... - -(addtest (lisp-stat-ut-dataclos) badAccess6 +;; NEVER REACH INTO CLASS INTERIORS, NO PROMISE +;; GUARANTEE OF LATER CONSISTENCY... + +(addtest (lisp-stat-ut-dataclos) df-consdata (ensure - (lisp-stat-data-clos::doc-string *my-df-1*)) + (lisp-stat-data-clos::doc-string my-df-1)) (ensure-error - (doc-string *my-df-1*))) - -(addtest (lisp-stat-ut-dataclos) badAccess7 + (doc-string my-df-1))) + +(addtest (lisp-stat-ut-dataclos) df-consdata (ensure - (lisp-stat-data-clos::case-labels *my-df-1*)) + (lisp-stat-data-clos::case-labels my-df-1)) (ensure-error - (case-labels *my-df-1*))) - -(addtest (lisp-stat-ut-dataclos) badAccess8 + (case-labels my-df-1))) + +(addtest (lisp-stat-ut-dataclos) df-consdata (ensure - (lisp-stat-data-clos::var-labels *my-df-1*)) + (lisp-stat-data-clos::var-labels my-df-1)) (ensure-error - (var-labels *my-df-1*))) + (var-labels my-df-1))) ;; need to ensure that for things like the following, that we protect ;; this a bit more so that the results are not going to to be wrong. @@ -135,48 +122,44 @@ (addtest (lisp-stat-ut-dataclos) badAccess9 (ensure - (setf (lisp-stat-data-clos::var-labels *my-df-1*) + (setf (lisp-stat-data-clos::var-labels my-df-1) (list "a" "b")))) - + (addtest (lisp-stat-ut-dataclos) badAccess10 (ensure (progn ;; no error, but corrupts structure - (setf (lisp-stat-data-clos::var-labels *my-df-1*) + (setf (lisp-stat-data-clos::var-labels my-df-1) (list "a" "b" "c")) ;; error happens here - (not (consistent-dataframe-like-p *my-df-1*))))) ;; Nil + (not (consistent-dataframe-p my-df-1))))) ;; Nil (addtest (lisp-stat-ut-dataclos) badAccess12 (ensure - (setf (lisp-stat-data-clos::var-labels *my-df-1*) + (setf (lisp-stat-data-clos::var-labels my-df-1) (list "a" "b")))) - + (addtest (lisp-stat-ut-dataclos) badAccess13 (ensure - (consistent-dataframe-like-p *my-df-1*))) ;; T - + (consistent-dataframe-p my-df-1))) ;; T + ;; This is now done by: (addtest (lisp-stat-ut-dataclos) badAccess14 (ensure-error - (let ((old-varnames (varNames *my-df-1*))) - (setf (varNames *my-df-1*) (list "a" "b")) ;; should error - (setf (varNames *my-df-1*) old-varnames) - (error "don't reach this point in badaccess14")))) - -;; break this up. -(defvar origCaseNames nil) - + (let ((old-varnames (varNames my-df-1))) + (setf (varNames my-df-1) (list "a" "b")) ;; should error + (setf (varNames my-df-1) old-varnames) + (error "don't reach this point in badaccess14")))) + (addtest (lisp-stat-ut-dataclos) badAccess15 (ensure - (progn - (setf origCaseNames (caseNames *my-df-1*)) - (setf (caseNames *my-df-1*) (list "a" "b" "c" 4 5)) - (caseNames *my-df-1*) + (let ((origCaseNames (caseNames my-df-1))) + (setf (caseNames my-df-1) (list "a" "b" "c" 4 5)) + (caseNames my-df-1) (ignore-errors - (setf (caseNames *my-df-1*) + (setf (caseNames my-df-1) (list "a" "b" 4 5))) - (setf (caseNames *my-df-1*) origCaseNames)))) + (setf (caseNames my-df-1) origCaseNames)))) ;;; ;; (run-tests) -- 2.11.4.GIT