source: trunk/source/tests/ansi-tests/mapcon.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: 1.9 KB
Line 
1;-*- Mode:     Lisp -*-
2;;;; Author:   Paul Dietz
3;;;; Created:  Sun Apr 20 07:24:28 2003
4;;;; Contains: Tests of MAPCON
5
6(in-package :cl-test)
7
8(compile-and-load "cons-aux.lsp")
9
10(deftest mapcon.1
11  (mapcon #'(lambda (x) (append '(a) x nil)) nil)
12  nil)
13
14(deftest mapcon.2
15  (let* ((x (copy-list '(1 2 3 4)))
16         (xcopy (make-scaffold-copy x))
17         (result
18          (mapcon #'(lambda (y) (append '(a) y nil)) x)))
19    (and
20     (check-scaffold-copy x xcopy)
21     result))
22  (a 1 2 3 4 a 2 3 4 a 3 4 a 4))
23
24(deftest mapcon.3
25  (let* ((x (copy-list '(4 2 3 2 2)))
26         (y (copy-list '(a b c d e f g h i j k l)))
27         (xcopy (make-scaffold-copy x))
28         (ycopy (make-scaffold-copy y))
29         (result
30          (mapcon #'(lambda (xt yt)
31                      (subseq yt 0 (car xt)))
32                  x y)))
33    (and
34     (check-scaffold-copy x xcopy)
35     (check-scaffold-copy y ycopy)
36     result))
37  (a b c d b c c d e d e e f))
38
39(deftest mapcon.4
40  (mapcon (constantly 1) (list 'a))
41  1)
42
43(deftest mapcon.order.1
44  (let ((i 0) x y z)
45    (values
46     (mapcon (progn (setf x (incf i))
47                    #'(lambda (x y) (list (car x) (car y))))
48             (progn (setf y (incf i))
49                    '(a b c))
50             (progn (setf z (incf i))
51                    '(1 2 3)))
52     i x y z))
53  (a 1 b 2 c 3)
54  3 1 2 3)
55
56(deftest mapcon.error.1
57  (check-type-error #'(lambda (x) (mapcon #'identity x)) #'listp)
58  nil)
59
60(deftest mapcon.error.2
61  (signals-error (mapcon) program-error)
62  t)
63
64(deftest mapcon.error.3
65  (signals-error (mapcon #'append) program-error)
66  t)
67
68(deftest mapcon.error.4
69  (signals-error (locally (mapcon #'identity 1) t) type-error)
70  t)
71
72(deftest mapcon.error.5
73  (signals-error (mapcon #'caar '(a b c)) type-error)
74  t)
75
76(deftest mapcon.error.6
77  (signals-error (mapcon #'cons '(a b c)) program-error)
78  t)
79
80(deftest mapcon.error.7
81  (signals-error (mapcon #'cons '(a b c) '(1 2 3) '(4 5 6)) program-error)
82  t)
83
84(deftest mapcon.error.8
85  (signals-error (mapcon #'copy-tree (cons 1 2)) type-error)
86  t)
Note: See TracBrowser for help on using the repository browser.