From ba7434a454847b3e18cfdea21c56ad15386ced6c Mon Sep 17 00:00:00 2001 From: pfdietz Date: Tue, 17 Jun 2003 12:43:11 +0000 Subject: [PATCH] Add extra class-of tests. Make compile-and-load remember what's been loaded and reload only when necessary (this will let me put a compile-and-load into files that require aux files, so it won't be necessary to compile/load the aux files separately. See search-*.lsp for examples.) --- ansi-tests/class-of.lsp | 16 ++++++++++++++++ ansi-tests/compile-and-load.lsp | 33 +++++++++++++++++++-------------- ansi-tests/load-objects.lsp | 3 ++- ansi-tests/search-bitvector.lsp | 2 ++ ansi-tests/search-list.lsp | 2 ++ ansi-tests/search-string.lsp | 2 ++ ansi-tests/search-vector.lsp | 2 ++ 7 files changed, 45 insertions(+), 15 deletions(-) create mode 100644 ansi-tests/class-of.lsp diff --git a/ansi-tests/class-of.lsp b/ansi-tests/class-of.lsp new file mode 100644 index 0000000..0752a70 --- /dev/null +++ b/ansi-tests/class-of.lsp @@ -0,0 +1,16 @@ +;-*- Mode: Lisp -*- +;;;; Author: Paul Dietz +;;;; Created: Mon Jun 16 19:40:32 2003 +;;;; Contains: Tests of CLASS-OF + +(in-package :cl-test) + +;;; Most tests of CLASS-OF are in other files + +(deftest class-of.error.1 + (classify-error (class-of)) + program-error) + +(deftest class-of.error.2 + (classify-error (class-of nil nil)) + program-error) diff --git a/ansi-tests/compile-and-load.lsp b/ansi-tests/compile-and-load.lsp index abdc3a2..435f2f6 100644 --- a/ansi-tests/compile-and-load.lsp +++ b/ansi-tests/compile-and-load.lsp @@ -12,24 +12,29 @@ (defun compile-file-pathname (pathname) (make-pathname :defaults pathname :type "o")))) -(defun compile-and-load (pathspec) +;;; On-demand compile and load + +(defvar *compiled-and-loaded-files* nil + "List containing pathname, creation times for files that have already + been loaded.") + +(defun compile-and-load (pathspec &key force) "Find the file indicated by PATHSPEC, compiling it first if the associated compiled file is out of date." (let* ((pathname (pathname pathspec)) + (former-data (assoc pathname *compiled-and-loaded-files* + :test #'equalp)) (compile-pathname (compile-file-pathname pathname)) (source-write-time (file-write-date pathname)) (target-write-time (and (probe-file compile-pathname) (file-write-date compile-pathname)))) - (when (or (not target-write-time) - (<= target-write-time source-write-time)) - (compile-file pathname)) - (load compile-pathname))) - -;;; On-demand compile and load - -(defvar *compiled-and-loaded-files* nil - "List containing pathname, creation times for files that have already - been loaded.") - - - + (unless (and (not force) + former-data + (<= (cadr former-data) source-write-time)) + (when (or (not target-write-time) + (<= target-write-time source-write-time)) + (compile-file pathname)) + (if former-data + (setf (cadr former-data) source-write-time) + (push (list pathname source-write-time) *compiled-and-loaded-files*)) + (load compile-pathname)))) diff --git a/ansi-tests/load-objects.lsp b/ansi-tests/load-objects.lsp index 3affa3c..7a0034b 100644 --- a/ansi-tests/load-objects.lsp +++ b/ansi-tests/load-objects.lsp @@ -51,5 +51,6 @@ (load "define-method-combination.lsp") (load "find-method.lsp") (load "add-method.lsp") -(load "unbound-slot.lsp") (load "class-name.lsp") +(load "class-of.lsp") +(load "unbound-slot.lsp") diff --git a/ansi-tests/search-bitvector.lsp b/ansi-tests/search-bitvector.lsp index 617f152..f73d47e 100644 --- a/ansi-tests/search-bitvector.lsp +++ b/ansi-tests/search-bitvector.lsp @@ -5,6 +5,8 @@ (in-package :cl-test) +(compile-and-load "search-aux.lsp") + (deftest search-bitvector.1 (let ((target *searched-bitvector*) (pat #*0)) diff --git a/ansi-tests/search-list.lsp b/ansi-tests/search-list.lsp index c93a7d7..2a5ad24 100644 --- a/ansi-tests/search-list.lsp +++ b/ansi-tests/search-list.lsp @@ -5,6 +5,8 @@ (in-package :cl-test) +(compile-and-load "search-aux.lsp") + (deftest search-list.1 (let ((target *searched-list*) (pat '(a))) diff --git a/ansi-tests/search-string.lsp b/ansi-tests/search-string.lsp index 0ea7c59..791d919 100644 --- a/ansi-tests/search-string.lsp +++ b/ansi-tests/search-string.lsp @@ -5,6 +5,8 @@ (in-package :cl-test) +(compile-and-load "search-aux.lsp") + ;;; The next test was busted due to to a stupid cut and paste ;;; error. The loop terminates immediately, doing nothing ;;; useful. -- PFD diff --git a/ansi-tests/search-vector.lsp b/ansi-tests/search-vector.lsp index 217bf4d..d2723ef 100644 --- a/ansi-tests/search-vector.lsp +++ b/ansi-tests/search-vector.lsp @@ -5,6 +5,8 @@ (in-package :cl-test) +(compile-and-load "search-aux.lsp") + (deftest search-vector.1 (let ((target *searched-vector*) (pat #(a))) -- GitLab