source: trunk/source/tests/ansi-tests/apropos-list.lsp @ 8991

Last change on this file since 8991 was 8991, checked in by gz, 11 years ago

Check in the gcl ansi test suite (original, in preparation for making local changes)

File size: 2.5 KB
Line 
1;-*- Mode:     Lisp -*-
2;;;; Author:   Paul Dietz
3;;;; Created:  Tue Dec 14 06:21:45 2004
4;;;; Contains: Tests of APROPOS-LIST
5
6(in-package :cl-test)
7
8(deftest apropos-list.1
9  (let ((pkg "CL-TEST-APROPOS-LIST-PACKAGE"))
10    (safely-delete-package pkg)
11    (unwind-protect
12        (progn
13          (eval `(defpackage ,pkg (:use)))
14          (let* ((sym (intern "FOO" pkg)))
15            (loop for p in (list pkg (find-package pkg) (make-symbol pkg))
16                  nconc
17                  (loop for string-designator in
18                        '("F" "O" #\F #\O "" "FOO" "FO"
19                          "OO" :|F| :|FO| :|FOO| :|O| :|OO|)
20                        for result = (apropos-list string-designator p)
21                        unless (equal result (list sym))
22                        collect (list string-designator result)))))
23      (safely-delete-package pkg)))
24  nil)
25
26(deftest apropos-list.2
27  (let ((pkg #\A))
28    (safely-delete-package pkg)
29    (unwind-protect
30        (progn
31          (eval `(defpackage ,pkg (:use)))
32          (let* ((sym (intern "FOO" pkg)))
33            (loop for string-designator in
34                  '("F" "O" #\F #\O "" "FOO" "FO"
35                    "OO" :|F| :|FO| :|FOO| :|O| :|OO|)
36                  for result = (apropos-list string-designator pkg)
37                  unless (equal result (list sym))
38                  collect (list string-designator result))))
39      (safely-delete-package pkg)))
40  nil)
41
42(deftest apropos-list.3
43  (let ((pkg "CL-TEST-APROPOS-LIST-PACKAGE"))
44    (safely-delete-package pkg)
45    (unwind-protect
46        (progn
47          (eval `(defpackage ,pkg (:use)))
48          (intern "FOO" pkg)
49          (apropos-list "X" pkg))
50      (safely-delete-package pkg)))
51  nil)
52
53(deftest apropos-list.4
54  (let ((sym :|X|)
55        (symbols (apropos-list "X")))
56    (notnot (member sym symbols)))
57  t)
58
59(deftest apropos-list.5
60  (let ((sym :|X|)
61        (symbols (apropos-list '#:|X|)))
62    (notnot (member sym symbols)))
63  t)
64
65(deftest apropos-list.6
66  (let ((sym :|X|)
67        (symbols (apropos-list #\X)))
68    (notnot (member sym symbols)))
69  t)
70
71(deftest apropos-list.7
72  (let ((sym :|X|)
73        (symbols (apropos-list "X" nil)))
74    (notnot (member sym symbols)))
75  t)
76
77(deftest apropos-list.8
78  (let ((*package* (find-package "COMMON-LISP")))
79    (macrolet
80     ((%m (z) z))
81     (intersection '(car)
82                   (apropos-list (expand-in-current-env (%m "CAR"))))))
83  (car))
84
85(deftest apropos-list.9
86  (macrolet
87   ((%m (z) z))
88   (intersection '(car)
89                 (apropos-list "CAR" (expand-in-current-env
90                                      (%m (find-package "COMMON-LISP"))))))
91  (car))
92
93;;; Error tests
94
95(deftest apropos-list.error.1
96  (signals-error (apropos-list) program-error)
97  t)
98
99(deftest apropos-list.error.2
100  (signals-error (apropos-list "X" (find-package "CL-TEST") nil) program-error)
101  t)
Note: See TracBrowser for help on using the repository browser.