source: trunk/source/tests/ansi-tests/nsubst-if-not.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.9 KB
Line 
1;-*- Mode:     Lisp -*-
2;;;; Author:   Paul Dietz
3;;;; Created:  Sat Apr 19 21:54:12 2003
4;;;; Contains: Tests of NSUBST-IF-NOT
5
6(in-package :cl-test)
7
8(compile-and-load "cons-aux.lsp")
9
10(deftest nsubst-if-not.1
11  (check-nsubst-if-not '(x) 'consp '(1 (1 2) (1 2 3) (1 2 3 4)))
12  ((x)
13   ((x) (x) x)
14   ((x) (x) (x) x)
15   ((x) (x) (x) (x) x)
16   x))
17
18(deftest nsubst-if-not.2
19  (check-nsubst-if-not 'a (complement #'listp)
20                       '((100 1) (2 3) (4 3 2 1) (a b c)))
21  a)
22
23(deftest nsubst-if-not.3
24  (check-nsubst-if-not 'c #'identity
25                       '((100 1) (2 3) (4 3 2 1) (a b c))
26                       :key (complement #'listp))
27  c)
28
29(deftest nsubst-if-not.4
30  (check-nsubst-if-not
31   40
32   #'(lambda (x) (not (eql x 17)))
33   '((17) (17 22) (17 22 31) (17 21 34 54))
34   :key #'(lambda (x)
35            (and (consp x)
36                 (car x))))
37  (40 40 40 40))
38
39(deftest nsubst-if-not.5
40  (check-nsubst-if-not 'a  #'(lambda (x) (not (eql x 'b)))
41                       '((a) (b) (c) (d))
42                       :key nil)
43  ((a) (a) (c) (d)))
44
45(deftest nsubst-if-not.6
46  (nsubst-if-not 'a #'null nil :bad t :allow-other-keys t)
47  nil)
48
49(deftest nsubst-if-not.7
50  (let ((i 0) w x y z)
51    (values
52     (nsubst-if-not
53      (progn (setf w (incf i)) 'a)
54      (progn (setf x (incf i)) #'(lambda (x) (not (eql x 'b))))
55      (progn (setf y (incf i)) (copy-list '(1 2 a b c)))
56      :key (progn (setf z (incf i)) #'identity))
57     i w x y z))
58  (1 2 a a c)
59  4 1 2 3 4)
60
61;;; Keywords tests for nsubst-if-not
62
63(deftest nsubst-if-not.allow-other-keys.1
64  (nsubst-if-not 'a #'identity nil :bad t :allow-other-keys t)
65  a)
66
67(deftest nsubst-if-not.allow-other-keys.2
68  (nsubst-if-not 'a #'identity nil :allow-other-keys t)
69  a)
70
71(deftest nsubst-if-not.allow-other-keys.3
72  (nsubst-if-not 'a #'identity nil :allow-other-keys nil)
73  a)
74
75(deftest nsubst-if-not.allow-other-keys.4
76  (nsubst-if-not 'a #'identity nil :allow-other-keys t :bad t)
77  a)
78
79(deftest nsubst-if-not.allow-other-keys.5
80  (nsubst-if-not 'a #'identity nil :allow-other-keys t :allow-other-keys nil :bad t)
81  a)
82
83(deftest nsubst-if-not.keywords.6
84  (nsubst-if-not 'a #'identity nil :key nil :key (constantly 'b))
85  a)
86
87;;; error cases
88
89(deftest nsubst-if-not.error.1
90  (signals-error (nsubst-if-not) program-error)
91  t)
92
93(deftest nsubst-if-not.error.2
94  (signals-error (nsubst-if-not 'a) program-error)
95  t)
96
97(deftest nsubst-if-not.error.3
98  (signals-error (nsubst-if-not 'a #'null) program-error)
99  t)
100
101(deftest nsubst-if-not.error.4
102  (signals-error (nsubst-if-not 'a #'null nil :foo nil) program-error)
103  t)
104
105(deftest nsubst-if-not.error.5
106  (signals-error (nsubst-if-not 'a #'null nil :test) program-error)
107  t)
108
109(deftest nsubst-if-not.error.6
110  (signals-error (nsubst-if-not 'a #'null nil 1) program-error)
111  t)
112
113(deftest nsubst-if-not.error.7
114  (signals-error (nsubst-if-not 'a #'null nil
115                                 :bad t :allow-other-keys nil) program-error)
116  t)
117
118(deftest nsubst-if-not.error.8
119  (signals-error (nsubst-if-not 'a #'null (list 'a nil 'c) :key #'cons) program-error)
120  t)
121
Note: See TracBrowser for help on using the repository browser.