1 (require :sb-introspect)
3 (defpackage :sb-introspect-test
4 (:use "SB-INTROSPECT" "CL"))
5 (in-package :sb-introspect-test)
7 (with-compilation-unit (:source-plist (list :test-outer "OUT"))
8 (load (compile-file (merge-pathnames "test.lisp" *load-pathname*))))
10 (assert (equal (function-arglist 'cl-user::one)
11 '(cl-user::a cl-user::b cl-user::c)))
12 (assert (equal (function-arglist 'the)
15 (let ((source (find-definition-source #'cl-user::one)))
16 (assert (= (definition-source-file-write-date source)
17 (file-write-date (merge-pathnames "test.lisp" *load-pathname*))))
18 (assert (equal (getf (definition-source-plist source) :test-outer)
21 (let ((plist (definition-source-plist
22 (find-definition-source #'cl-user::four))))
23 (assert (equal (getf plist :test-outer) "OUT"))
24 (assert (equal (getf plist :test-inner) "IN")))
26 (defun matchp (object form-number)
27 (let ((ds (sb-introspect:find-definition-source object)))
28 (and (pathnamep (sb-introspect:definition-source-pathname ds))
30 (first (sb-introspect:definition-source-form-path ds))))))
32 (defun matchp-name (type object form-number)
33 (let ((ds (car (sb-introspect:find-definition-sources-by-name object type))))
34 (and (pathnamep (sb-introspect:definition-source-pathname ds))
36 (first (sb-introspect:definition-source-form-path ds))))))
38 (defun matchp-length (type object form-numbers)
39 (let ((ds (sb-introspect:find-definition-sources-by-name object type)))
40 (= (length ds) form-numbers)))
42 (assert (matchp-name :function 'cl-user::one 2))
43 (assert (matchp #'cl-user::one 2))
44 (assert (matchp-name :generic-function 'cl-user::two 3))
45 (assert (matchp (car (sb-pcl:generic-function-methods #'cl-user::two)) 4))
47 (assert (matchp-name :variable 'cl-user::*a* 8))
48 (assert (matchp-name :variable 'cl-user::*b* 9))
49 (assert (matchp-name :class 'cl-user::a 10))
50 (assert (matchp-name :condition 'cl-user::b 11))
51 (assert (matchp-name :structure 'cl-user::c 12))
52 (assert (matchp-name :function 'cl-user::make-c 12))
53 (assert (matchp-name :function 'cl-user::c-e 12))
54 (assert (matchp-name :structure 'cl-user::d 13))
55 (assert (matchp-name :function 'cl-user::make-d 13))
56 (assert (matchp-name :function 'cl-user::d-e 13))
57 (assert (matchp-name :package 'cl-user::e 14))
58 (assert (matchp-name :symbol-macro 'cl-user::f 15))
59 (assert (matchp-name :type 'cl-user::g 16))
60 (assert (matchp-name :constant 'cl-user::+h+ 17))
61 (assert (matchp-length :method 'cl-user::j 2))
62 (assert (matchp-name :macro 'cl-user::l 20))
63 (assert (matchp-name :compiler-macro 'cl-user::m 21))
64 (assert (matchp-name :setf-expander 'cl-user::n 22))
65 (assert (matchp-name :function '(setf cl-user::o) 23))
66 (assert (matchp-name :method '(setf cl-user::p) 24))
67 (assert (matchp-name :macro 'cl-user::q 25))
68 (assert (matchp-name :method-combination 'cl-user::r 26))
69 (assert (matchp-name :setf-expander 'cl-user::s 27))
71 (sb-profile:profile cl-user::one)
72 (assert (matchp-name :function 'cl-user::one 2))
73 (sb-profile:unprofile cl-user::one)
75 ;;; Test the xref facility
77 (load (merge-pathnames "xref-test.lisp" *load-pathname*))
79 ;;; Unix success convention for exit codes
80 (sb-ext:quit :unix-status 0)