-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathapply.lsp
77 lines (60 loc) · 1.52 KB
/
apply.lsp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
;-*- Mode: Lisp -*-
;;;; Author: Paul Dietz
;;;; Created: Mon Jan 13 15:13:07 2003
;;;; Contains: Tests of APPLY
(in-package :cl-test)
;;; Error cases
(deftest apply.error.1
(signals-error (apply) program-error)
t)
(deftest apply.error.2
(signals-error (apply #'cons) program-error)
t)
(deftest apply.error.3
(signals-error (apply #'cons nil) program-error)
t)
(deftest apply.error.4
(signals-error (apply #'cons (list 1 2 3))
program-error)
t)
;;; Non-error cases
(deftest apply.1
(apply #'cons 'a 'b nil)
(a . b))
(deftest apply.2
(apply #'cons 'a '(b))
(a . b))
(deftest apply.3
(apply #'cons '(a b))
(a . b))
(deftest apply.4
(let ((zeros (make-list (min 10000 (1- call-arguments-limit))
:initial-element 1)))
(apply #'+ zeros))
#.(min 10000 (1- call-arguments-limit)))
(deftest apply.5
(apply 'cons '(a b))
(a . b))
(deftest apply.6
(macrolet ((%m (z) z))
(apply (expand-in-current-env (%m 'cons)) 1 2 nil))
(1 . 2))
(deftest apply.7
(macrolet ((%m (z) z))
(apply #'cons (expand-in-current-env (%m 1)) '(2)))
(1 . 2))
(deftest apply.8
(macrolet ((%m (z) z))
(apply #'cons (expand-in-current-env (%m '(1 2)))))
(1 . 2))
(deftest apply.order.1
(let ((i 0) x y z)
(values
(apply (progn (setf x (incf i))
#'list)
(progn (setf y (incf i))
'b)
(progn (setf z (incf i))
(list 'a)))
i x y z))
(b a) 3 1 2 3)