source: trunk/source/tests/ansi-tests/the.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: 3.2 KB
Line 
1;-*- Mode:     Lisp -*-
2;;;; Author:   Paul Dietz
3;;;; Created:  Tue May  6 06:48:48 2003
4;;;; Contains: Tests of THE
5
6(in-package :cl-test)
7
8(deftest the.1
9  (the (values) (values)))
10
11(deftest the.2
12  (the (values) 'a)
13  a)
14
15(deftest the.3
16  (check-predicate #'(lambda (e)
17                       (let ((x (multiple-value-list (eval `(the (values) (quote ,e))))))
18                         (and x (not (cdr x)) (eql (car x) e)))))
19  nil)
20
21(deftest the.4
22  (check-predicate #'(lambda (e)
23                       (let ((x (multiple-value-list (eval `(the ,(type-of e) (quote ,e))))))
24                         (and x (not (cdr x)) (eql (car x) e)))))
25  nil)
26
27(deftest the.5
28  (check-predicate #'(lambda (e)
29                       (let ((x (multiple-value-list (eval `(the (values ,(type-of e)) (quote ,e))))))
30                         (and x (not (cdr x)) (eql (car x) e)))))
31  nil)
32
33(deftest the.6
34  (check-predicate #'(lambda (e)
35                       (let ((x (multiple-value-list (eval `(the (values ,(type-of e) t) (quote ,e))))))
36                         (and x (not (cdr x)) (eql (car x) e)))))
37  nil)
38
39(deftest the.7
40  (check-predicate
41   #'(lambda (e)
42       (let ((x (multiple-value-list (eval `(the (values ,(type-of e))
43                                              (values (quote ,e) :ignored))))))
44         (and (eql (length x) 2)
45              (eql (car x) e)
46              (eql (cadr x) :ignored)))))
47  nil)
48
49(deftest the.8
50  (check-predicate #'(lambda (e) (or (not (constantp e))
51                                     (eql (eval `(the ,(type-of e) ,e)) e))))
52  nil)
53
54(deftest the.9
55  (check-predicate #'(lambda (e) (or (not (constantp e))
56                                     (eql (eval `(the ,(class-of e) ,e)) e))))
57  nil)
58
59(deftest the.10
60  (check-predicate #'(lambda (e) (eql (eval `(the ,(class-of e) ',e)) e)))
61  nil)
62
63(deftest the.11
64  (check-predicate
65   #'(lambda (e)
66       (let* ((type (type-of e))
67              (x (multiple-value-list (eval `(the ,type (the ,type (quote ,e)))))))
68         (and x (not (cdr x)) (eql (car x) e)))))
69  nil)
70
71(deftest the.12
72  (let ((lexpr
73         `(lambda ()
74            (and
75             ,@(loop for e in *mini-universe*
76                     for type = (type-of e)
77                     collect `(eqlt (quote ,e) (the ,type (quote ,e))))))))
78    (funcall (compile nil lexpr)))
79  t)
80
81(deftest the.13
82  (let ((x 0))
83    (values
84     (the (or symbol integer) (incf x))
85     x))
86  1 1)
87
88(deftest the.14
89  (the (values &rest t) (values 'a 'b))
90  a b)
91
92(deftest the.15
93  (the (values &rest symbol) (values 'a 'b))
94  a b)
95
96(deftest the.16
97  (the (values &rest null) (values)))
98
99(deftest the.17
100  (the (values symbol integer &rest null) (values 'a 1))
101  a 1)
102
103(deftest the.18
104  (the (values symbol integer &rest t) (values 'a 1 'foo '(x y)))
105  a 1 foo (x y))
106
107(deftest the.19
108  (let () (list (the (values) (eval '(values)))))
109  (nil))
110
111;;; This is from SBCL bug 261
112(deftest the.20
113  (let () (list (the (values &optional fixnum) (eval '(values)))))
114  (nil))
115
116(deftest the.21
117  (let () (list (the (values &rest t) (eval '(values)))))
118  (nil))
119
120(deftest the.22
121  (the (values symbol integer &rest t) (eval '(values 'a 1 'foo '(x y))))
122  a 1 foo (x y))
123
124(deftest the.23
125  (multiple-value-list
126   (the (values symbol integer &optional fixnum) (eval '(values 'a 1))))
127  (a 1))
128
129;;; Test that explicit calls to macroexpand in subforms
130;;; are done in the correct environment
131
132(deftest the.24
133  (macrolet
134   ((%m (z) z))
135   (the (integer 0 10) (expand-in-current-env (%m 4))))
136  4)
137
138(deftest the.25
139  (macrolet
140   ((%m (z) z))
141   (the (values t t) (expand-in-current-env (%m (values 1 2)))))
142  1 2)
143
Note: See TracBrowser for help on using the repository browser.