X-Git-Url: http://repo.macrolet.net/gitweb/?a=blobdiff_plain;f=contrib%2Fsb-introspect%2Ftest-driver.lisp;h=c38d9f576a8dc62a22f700de68a2e9e6c7c1f24e;hb=aa8cdb795d6bb551aaecb6db38d5ef6571c698ed;hp=e5d7cd1a316b74adc37295ca8eefbc16cecd9eb1;hpb=e119a2f79cf36039a39996f5490934b4d927529a;p=sbcl.git diff --git a/contrib/sb-introspect/test-driver.lisp b/contrib/sb-introspect/test-driver.lisp index e5d7cd1..c38d9f5 100644 --- a/contrib/sb-introspect/test-driver.lisp +++ b/contrib/sb-introspect/test-driver.lisp @@ -7,12 +7,12 @@ (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) +(assert (equal (function-lambda-list 'cl-user::one) '(cl-user::a cl-user::b cl-user::c))) -(assert (equal (function-arglist 'the) +(assert (equal (function-lambda-list 'the) '(sb-c::value-type sb-c::form))) -(assert (equal (function-arglist #'(sb-pcl::slow-method cl-user::j (t))) +(assert (equal (function-lambda-list #'(sb-pcl::slow-method cl-user::j (t))) '(sb-pcl::method-args sb-pcl::next-methods))) (let ((source (find-definition-source #'cl-user::one))) @@ -71,16 +71,20 @@ (assert (matchp-name :method-combination 'cl-user::r 26)) (assert (matchp-name :setf-expander 'cl-user::s 27)) +(let ((fin (make-instance 'sb-mop:funcallable-standard-object))) + (sb-mop:set-funcallable-instance-function fin #'cl-user::one) + (assert (matchp fin 2))) + (sb-profile:profile cl-user::one) (assert (matchp-name :function 'cl-user::one 2)) (sb-profile:unprofile cl-user::one) -;;;; Check correctness of FUNCTION-ARGLIST. +;;;; Check correctness of FUNCTION-LAMBDA-LIST. -(assert (equal (function-arglist 'cl-user::one) +(assert (equal (function-lambda-list 'cl-user::one) '(cl-user::a cl-user::b cl-user::c))) -(assert (equal (function-arglist 'the) +(assert (equal (function-lambda-list 'the) '(sb-c::value-type sb-c::form))) ;;; Check wrt. interplay of generic functions and their methods. @@ -99,7 +103,7 @@ ;; (multiple-value-bind (required optional restp rest keyp keys allowp auxp aux morep more-context more-count) - (sb-int:parse-lambda-list (function-arglist #'xuuq)) + (sb-int:parse-lambda-list (function-lambda-list #'xuuq)) (assert (equal required '(gf.a gf.b))) (assert (null optional)) (assert (and restp (eql rest 'gf.rest))) @@ -117,12 +121,90 @@ (defmethod kroolz (r1 r2 &optional opt &aux aux) (declare (ignore r1 r2 opt aux)) 'kroolz) -(assert (equal (function-arglist #'kroolz) '(r1 r2 &optional opt))) +(assert (equal (function-lambda-list #'kroolz) '(r1 r2 &optional opt))) + +;;;; Test finding a type that isn't one +(assert (not (find-definition-sources-by-name 'fboundp :type))) + +;;;; Check correctness of DEFTYPE-LAMBDA-LIST. +(deftype foobar-type + (&whole w &environment e r1 r2 &optional o &rest rest &key k1 k2 k3) + (declare (ignore w e r1 r2 o rest k1 k2 k3)) + nil) + +(assert (multiple-value-bind (arglist found?) (deftype-lambda-list 'foobar-type) + (and found? + (equal arglist '(&whole w &environment e + r1 r2 &optional o &rest rest &key k1 k2 k3))))) + +(assert (equal (multiple-value-list (deftype-lambda-list (gensym))) + '(nil nil))) ;;;; Test the xref facility (load (merge-pathnames "xref-test.lisp" *load-pathname*)) +;;; Test allocation-information + +(defun tai (x kind info) + (multiple-value-bind (kind2 info2) (sb-introspect:allocation-information x) + (unless (eq kind kind2) + (error "wanted ~S, got ~S" kind kind2)) + (assert (equal info info2)))) + +(tai nil :heap '(:space :static)) +(tai t :heap '(:space :static)) +(tai 42 :immediate nil) +(tai #'cons :heap + #+(and (not ppc) gencgc) + ;; FIXME: This is the canonical GENCGC result, the one below for PPC is + ;; what we get there, but :LARGE T doesn't seem right. Figure out what's + ;; going on. + '(:space :dynamic :generation 6 :write-protected t :pinned nil :large nil) + #+(and ppc gencgc) + '(:space :dynamic :generation 6 :write-protected t :pinned nil :large t) + ;; FIXME: Figure out what's the right cheney-result, and which platforms + ;; return something else. The SPARC version here is what we get there, + ;; but quite possibly that is the result on all non-GENCGC platforms. + #+(and sparc (not gencgc)) + '(:space :read-only) + #+(and (not sparc) (not gencgc)) + '(:space :dynamic)) +#+sb-thread +(let ((x (list 1 2 3))) + (declare (dynamic-extent x)) + (tai x :stack sb-thread:*current-thread*)) +#+sb-thread +(progn + (defun thread-tai () + (let ((x (list 1 2 3))) + (declare (dynamic-extent x)) + (let ((child (sb-thread:make-thread + (lambda () + (sb-introspect:allocation-information x))))) + (assert (equal (list :stack sb-thread:*current-thread*) + (multiple-value-list (sb-thread:join-thread child))))))) + (thread-tai) + (defun thread-tai2 () + (let* ((sem (sb-thread:make-semaphore)) + (obj nil) + (child (sb-thread:make-thread + (lambda () + (let ((x (list 1 2 3))) + (declare (dynamic-extent x)) + (setf obj x) + (sb-thread:wait-on-semaphore sem))) + :name "child"))) + (loop until obj) + (assert (equal (list :stack child) + (multiple-value-list + (sb-introspect:allocation-information obj)))) + (sb-thread:signal-semaphore sem) + (sb-thread:join-thread child) + nil)) + (thread-tai2)) + ;;;; Unix success convention for exit codes (sb-ext:quit :unix-status 0) +