~ubuntu-branches/ubuntu/quantal/gclcvs/quantal

« back to all changes in this revision

Viewing changes to ansi-tests/maplist.lsp

  • Committer: Bazaar Package Importer
  • Author(s): Camm Maguire
  • Date: 2004-06-24 15:13:46 UTC
  • Revision ID: james.westby@ubuntu.com-20040624151346-xh0xaaktyyp7aorc
Tags: 2.7.0-26
C_GC_OFFSET is 2 on m68k-linux

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
;-*- Mode:     Lisp -*-
 
2
;;;; Author:   Paul Dietz
 
3
;;;; Created:  Sun Apr 20 07:24:00 2003
 
4
;;;; Contains: Tests of MAPLIST
 
5
 
 
6
(in-package :cl-test)
 
7
 
 
8
(compile-and-load "cons-aux.lsp")
 
9
 
 
10
(deftest maplist.1
 
11
  (maplist #'list nil)
 
12
  nil)
 
13
 
 
14
(deftest maplist.2
 
15
  (let* ((x (copy-list '(a b c)))
 
16
         (xcopy (make-scaffold-copy x))
 
17
         (result (maplist #'identity x)))
 
18
    (and (check-scaffold-copy x xcopy)
 
19
         result))
 
20
  ((a b c) (b c) (c)))
 
21
 
 
22
(deftest maplist.3
 
23
  (let* ((x (copy-list '(a b c d)))
 
24
         (y (copy-list '(1 2 3 4)))
 
25
         (xcopy (make-scaffold-copy x))
 
26
         (ycopy (make-scaffold-copy y))
 
27
         (result
 
28
          (maplist #'append x y)))
 
29
    (and
 
30
     (check-scaffold-copy x xcopy)
 
31
     (check-scaffold-copy y ycopy)
 
32
     result))
 
33
  ((a b c d 1 2 3 4)
 
34
   (b c d 2 3 4)
 
35
   (c d 3 4)
 
36
   (d 4)))
 
37
 
 
38
(deftest maplist.4
 
39
  (let* ((x (copy-list '(a b c d)))
 
40
         (y (copy-list '(1 2 3 4 5)))
 
41
         (xcopy (make-scaffold-copy x))
 
42
         (ycopy (make-scaffold-copy y))
 
43
         (result
 
44
          (maplist #'append x y)))
 
45
    (and
 
46
     (check-scaffold-copy x xcopy)
 
47
     (check-scaffold-copy y ycopy)
 
48
     result))
 
49
  ((a b c d 1 2 3 4 5)
 
50
   (b c d 2 3 4 5)
 
51
   (c d 3 4 5)
 
52
   (d 4 5)))
 
53
 
 
54
(deftest maplist.5
 
55
  (let* ((x (copy-list '(a b c d e)))
 
56
         (y (copy-list '(1 2 3 4)))
 
57
         (xcopy (make-scaffold-copy x))
 
58
         (ycopy (make-scaffold-copy y))
 
59
         (result
 
60
          (maplist #'append x y)))
 
61
    (and
 
62
     (check-scaffold-copy x xcopy)
 
63
     (check-scaffold-copy y ycopy)
 
64
     result))
 
65
  ((a b c d e 1 2 3 4)
 
66
   (b c d e 2 3 4)
 
67
   (c d e 3 4)
 
68
   (d e 4)))
 
69
 
 
70
(deftest maplist.6
 
71
  (maplist 'append '(a b c) '(1 2 3))
 
72
  ((a b c 1 2 3) (b c 2 3) (c 3)))
 
73
 
 
74
(deftest maplist.7
 
75
  (maplist #'(lambda (x y) (nth (car x) y))
 
76
           '(0 1 0 1 0 1 0)
 
77
           '(a b c d e f g)
 
78
           )
 
79
  (a c c e e g g))
 
80
 
 
81
(deftest maplist.order.1
 
82
  (let ((i 0) x y z)
 
83
    (values
 
84
     (maplist
 
85
      (progn
 
86
        (setf x (incf i))
 
87
        #'(lambda (x y) (declare (ignore x)) (car y)))
 
88
      (progn
 
89
        (setf y (incf i))
 
90
        '(a b c))
 
91
      (progn
 
92
        (setf z (incf i))
 
93
             '(1 2 3)))
 
94
     i x y z))
 
95
  (1 2 3) 3 1 2 3)
 
96
 
 
97
(deftest maplist.error.1
 
98
  (signals-error (maplist #'identity 'a) type-error)
 
99
  t)
 
100
 
 
101
(deftest maplist.error.2
 
102
  (signals-error (maplist #'identity 1) type-error)
 
103
  t)
 
104
 
 
105
(deftest maplist.error.3
 
106
  (signals-error (maplist #'identity 1.1323) type-error)
 
107
  t)
 
108
 
 
109
(deftest maplist.error.4
 
110
  (signals-error (maplist #'identity "abcde") type-error)
 
111
  t)
 
112
 
 
113
(deftest maplist.error.5
 
114
  (signals-error (maplist) program-error)
 
115
  t)
 
116
 
 
117
(deftest maplist.error.6
 
118
  (signals-error (maplist #'append) program-error)
 
119
  t)
 
120
 
 
121
(deftest maplist.error.7
 
122
  (signals-error (locally (maplist #'identity 'a) t) type-error)
 
123
  t)
 
124
 
 
125
(deftest maplist.error.8
 
126
  (signals-error (maplist #'caar '(a b c)) type-error)
 
127
  t)
 
128
 
 
129
(deftest maplist.error.9
 
130
  (signals-error (maplist #'cons '(a b c)) program-error)
 
131
  t)
 
132
 
 
133
(deftest maplist.error.10
 
134
  (signals-error (maplist #'cons '(a b c) '(1 2 3) '(4 5 6))
 
135
                 program-error)
 
136
  t)
 
137
 
 
138
(deftest maplist.error.11
 
139
  (signals-error (maplist #'identity (list* (list 1) (list 2) 3))
 
140
                 type-error)
 
141
  t)
 
142
 
 
143