1.0.30.35: turn SB-INTROSPECT into an ASDF system
[sbcl.git] / contrib / sb-introspect / xref-test.lisp
1 ;;;; This software is part of the SBCL system. See the README file for
2 ;;;; more information.
3 ;;;;
4 ;;;; This software is derived from the CMU CL system, which was
5 ;;;; written at Carnegie Mellon University and released into the
6 ;;;; public domain. The software is in the public domain and is
7 ;;;; provided with absolutely no warranty. See the COPYING and CREDITS
8 ;;;; files for more information.
9
10 (in-package :sb-introspect-test/xref)
11
12 (deftest xrefs
13     (labels ((natural< (a b)
14                (string< (princ-to-string a) (princ-to-string b))))
15       (let ((tests '(((sb-introspect::who-calls 'foo) ())
16                      ((sb-introspect::who-calls 'bar) (xref/1 xref/3))
17                      ((sb-introspect::who-calls 'xref/1) (xref/2))
18                      ((sb-introspect::who-calls 'xref/2)
19                       (xref/5 xref/6 xref/8 xref/8 xref/12
20                        (sb-pcl::fast-method xref/10
21                                             (t t t t t t t t fixnum))
22                        (sb-pcl::fast-method xref/11 (fixnum))))
23                      ((sb-introspect::who-calls 'xref/3)
24                       (inline/1 (sb-pcl::fast-method xref/11 (float))))
25                      ((sb-introspect::who-calls 'xref/4) ())
26                      ((sb-introspect::who-calls 'xref/5) ())
27                      ((sb-introspect::who-calls 'xref/6) (xref/7))
28                      ((sb-introspect::who-calls 'xref/7) ())
29                      ((sb-introspect::who-calls 'xref/8) ())
30                      ((sb-introspect::who-calls 'xref/10) ())
31                      ((sb-introspect::who-calls 'xref/11) ())
32                      ((sb-introspect::who-calls 'inline/1) (xref/12))
33                      ((sb-introspect::who-calls 'xref/12) (macro/1))
34                      ((sb-introspect::who-macroexpands 'macro/1)
35                       (macro-use/1 macro-use/2 macro-use/3 macro-use/4 inline/2))
36                      ((sb-introspect::who-binds '*a*) (xref/2))
37                      ((sb-introspect::who-sets '*a*) (xref/2 xref/13))
38                      ((sb-introspect::who-references '*a*)
39                       (xref/1 xref/2 xref/4 inline/1 xref/14))
40                      ((sb-introspect::who-references '+z+)
41                       (inline/1)))))
42         (loop for x in tests
43               for form = (first x)
44               for wanted = (sort (second x) #'natural<)
45               for result = (sort (loop for name in (eval form)
46                                        collect (car name))
47                                  #'natural<)
48               do (unless (equalp wanted result)
49                    (return (format nil "form=~a~%wanted=~a~%result=~a~%"
50                                    form wanted result))))))
51   nil)