source: trunk/source/tests/ansi-tests/funcall.lsp @ 8991

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

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

File size: 2.1 KB
Line 
1;-*- Mode:     Lisp -*-
2;;;; Author:   Paul Dietz
3;;;; Created:  Wed Oct  9 21:45:07 2002
4;;;; Contains: Tests of FUNCALL
5
6(in-package :cl-test)
7
8(deftest funcall.1
9  (let ((fn #'cons))
10    (funcall fn 'a 'b))
11  (a . b))
12
13(deftest funcall.2
14  (funcall (symbol-function 'cons) 'a 'b)
15  (a . b))
16
17(deftest funcall.3
18  (let ((fn 'cons))
19    (funcall fn 'a 'b))
20  (a . b))
21
22(deftest funcall.4
23  (funcall 'cons 'a 'b)
24  (a . b))
25
26(deftest funcall.5
27  (let ((fn #'+))
28    (funcall fn 1 2 3 4))
29  10)
30
31(deftest funcall.6
32  (funcall #'(lambda (x y) (cons x y)) 'a 'b)
33  (a . b))
34
35(defun xcons (x y) (cons x y))
36
37(deftest funcall.7
38  (flet ((xcons (x y) (list y x)))
39    (values (funcall 'xcons 1 2)
40            (funcall #'xcons 1 2)))
41  (1 . 2)
42  (2 1))
43
44(deftest funcall.8
45  (flet ((foo (x y z) (values x y z)))
46    (funcall #'foo 1 2 3))
47  1 2 3)
48
49(deftest funcall.9
50  (flet ((foo () (values)))
51    (funcall #'foo))
52  )
53
54(deftest funcall.order.1
55  (let ((i 0) a b)
56    (values
57     (funcall (progn (setf a (incf i)) #'car)
58              (progn (setf b (incf i)) '(x . y)))
59     i a b))
60  x 2 1 2)
61
62(deftest funcall.order.2
63  (let ((i 0) a b c)
64    (values
65     (funcall (progn (setf a (incf i)) #'cons)
66              (progn (setf b (incf i)) 'x)
67              (progn (setf c (incf i)) 'y))
68     i a b c))
69  (x . y) 3 1 2 3)
70
71
72;;; FUNCALL should throw an UNDEFINED-FUNCTION condition when
73;;; called on a symbol with a global definition as a special
74;;; operator
75(deftest funcall.error.1
76  (signals-error (funcall 'quote 1) undefined-function :name quote)
77  t)
78
79(deftest funcall.error.2
80  (signals-error (funcall 'progn 1) undefined-function :name progn)
81  t)
82
83;;; FUNCALL should throw an UNDEFINED-FUNCTION condition when
84;;; called on a symbol with a global definition as a macro
85(deftest funcall.error.3
86  (signals-error (funcall 'defconstant '(defconstant x 10))
87                 undefined-function
88                 :name defconstant)
89  t)
90
91(deftest funcall.error.4
92  (signals-error (funcall) program-error)
93  t)
94
95(deftest funcall.error.5
96  (signals-error (funcall #'cons) program-error)
97  t)
98
99(deftest funcall.error.6
100  (signals-error (funcall #'cons 1) program-error)
101  t)
102
103(deftest funcall.error.7
104  (signals-type-error x 'a (funcall #'car x))
105  t)
Note: See TracBrowser for help on using the repository browser.