X-Git-Url: http://repo.macrolet.net/gitweb/?a=blobdiff_plain;f=contrib%2Fsb-introspect%2Ftest-driver.lisp;h=f647fabacf1f53610a93dec719c0d79622170daa;hb=31f072311935e32751508ecf824905c6b58a1d95;hp=334b4898cd26803487c87cb859ef488b76290308;hpb=ab9ae982b1b242fc1b25547b5ef5939ee44aec1c;p=sbcl.git diff --git a/contrib/sb-introspect/test-driver.lisp b/contrib/sb-introspect/test-driver.lisp index 334b489..f647fab 100644 --- a/contrib/sb-introspect/test-driver.lisp +++ b/contrib/sb-introspect/test-driver.lisp @@ -4,26 +4,70 @@ (:use "SB-INTROSPECT" "CL")) (in-package :sb-introspect-test) -(load (compile-file (merge-pathnames "test.lisp" *load-pathname*))) +(with-compilation-unit (:source-plist (list :test-outer "OUT")) + (load (compile-file (merge-pathnames "test.lisp" *load-pathname*)))) (assert (equal (function-arglist 'cl-user::one) - '(cl-user::a cl-user::b cl-user::c))) + '(cl-user::a cl-user::b cl-user::c))) (assert (equal (function-arglist 'the) - '(type sb-c::value))) -(assert (= (definition-source-file-write-date - (find-definition-source 'cl-user::one)) - (file-write-date (merge-pathnames "test.lisp" *load-pathname*)))) + '(type sb-c::value))) + +(let ((source (find-definition-source #'cl-user::one))) + (assert (= (definition-source-file-write-date source) + (file-write-date (merge-pathnames "test.lisp" *load-pathname*)))) + (assert (equal (getf (definition-source-plist source) :test-outer) + "OUT"))) + +(let ((plist (definition-source-plist + (find-definition-source #'cl-user::four)))) + (assert (equal (getf plist :test-outer) "OUT")) + (assert (equal (getf plist :test-inner) "IN"))) (defun matchp (object form-number) (let ((ds (sb-introspect:find-definition-source object))) (and (pathnamep (sb-introspect:definition-source-pathname ds)) - (= form-number + (= form-number + (first (sb-introspect:definition-source-form-path ds)))))) + +(defun matchp-name (type object form-number) + (let ((ds (car (sb-introspect:find-definition-sources-by-name object type)))) + (and (pathnamep (sb-introspect:definition-source-pathname ds)) + (= form-number (first (sb-introspect:definition-source-form-path ds)))))) -(assert (matchp 'cl-user::one 2)) +(defun matchp-length (type object form-numbers) + (let ((ds (sb-introspect:find-definition-sources-by-name object type))) + (= (length ds) form-numbers))) + +(assert (matchp-name :function 'cl-user::one 2)) (assert (matchp #'cl-user::one 2)) -; (assert (matchp 'two 2)) ; defgenerics don't work yet +(assert (matchp-name :generic-function 'cl-user::two 3)) (assert (matchp (car (sb-pcl:generic-function-methods #'cl-user::two)) 4)) +(assert (matchp-name :variable 'cl-user::*a* 8)) +(assert (matchp-name :variable 'cl-user::*b* 9)) +(assert (matchp-name :class 'cl-user::a 10)) +(assert (matchp-name :condition 'cl-user::b 11)) +(assert (matchp-name :structure 'cl-user::c 12)) +(assert (matchp-name :function 'cl-user::make-c 12)) +(assert (matchp-name :function 'cl-user::c-e 12)) +(assert (matchp-name :structure 'cl-user::d 13)) +(assert (matchp-name :function 'cl-user::make-d 13)) +(assert (matchp-name :function 'cl-user::d-e 13)) +(assert (matchp-name :package 'cl-user::e 14)) +(assert (matchp-name :symbol-macro 'cl-user::f 15)) +(assert (matchp-name :type 'cl-user::g 16)) +(assert (matchp-name :constant 'cl-user::+h+ 17)) +(assert (matchp-length :method 'cl-user::j 2)) +(assert (matchp-name :macro 'cl-user::l 20)) +(assert (matchp-name :compiler-macro 'cl-user::m 21)) +(assert (matchp-name :setf-expander 'cl-user::n 22)) +(assert (matchp-name :function '(setf cl-user::o) 23)) +(assert (matchp-name :method '(setf cl-user::p) 24)) +(assert (matchp-name :macro 'cl-user::q 25)) +(assert (matchp-name :method-combination 'cl-user::r 26)) +(assert (matchp-name :setf-expander 'cl-user::s 27)) + + ;;; Unix success convention for exit codes (sb-ext:quit :unix-status 0)