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

« back to all changes in this revision

Viewing changes to ansi-tests/rassoc-if-not.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:35:27 2003
 
4
;;;; Contains: Tests of RASSOC-IF-NOT
 
5
 
 
6
(in-package :cl-test)
 
7
 
 
8
(compile-and-load "cons-aux.lsp")
 
9
 
 
10
(deftest rassoc-if-not.1
 
11
    (let* ((x (rev-assoc-list '((1 . a) (3 . b) (6 . c) (7 . d))))
 
12
           (xcopy (make-scaffold-copy x))
 
13
           (result (rassoc-if-not #'oddp x)))
 
14
      (and
 
15
       (check-scaffold-copy x xcopy)
 
16
       (eqt result (third x))
 
17
       result))
 
18
  (c . 6))
 
19
 
 
20
(deftest rassoc-if-not.2
 
21
  (let* ((x (rev-assoc-list '((1 . a) (3 . b) (6 . c) (7 . d))))
 
22
         (xcopy (make-scaffold-copy x))
 
23
         (result (rassoc-if-not #'evenp x :key #'1+)))
 
24
    (and
 
25
     (check-scaffold-copy x xcopy)
 
26
     (eqt result (third x))
 
27
     result))
 
28
  (c . 6))
 
29
 
 
30
(deftest rassoc-if-not.3
 
31
    (let* ((x (rev-assoc-list '((1 . a) nil (3 . b) (6 . c) (7 . d))))
 
32
           (xcopy (make-scaffold-copy x))
 
33
           (result (rassoc-if-not #'oddp x)))
 
34
      (and
 
35
       (check-scaffold-copy x xcopy)
 
36
       (eqt result (fourth x))
 
37
       result))
 
38
  (c . 6))
 
39
 
 
40
(deftest rassoc-if-not.4
 
41
    (rassoc-if-not #'identity 
 
42
                   (rev-assoc-list '((a . b) nil (c . d) (nil . e) (f . g))))
 
43
  (e))
 
44
 
 
45
;;; Order of argument evaluation
 
46
 
 
47
(deftest rassoc-if-not.order.1
 
48
  (let ((i 0) x y)
 
49
    (values
 
50
     (rassoc-if-not (progn (setf x (incf i)) #'identity)
 
51
                    (progn (setf y (incf i))
 
52
                           '((1 . a) (2 . b) (17) (4 . d))))
 
53
     i x y))
 
54
  (17) 2 1 2)
 
55
 
 
56
(deftest rassoc-if-not.order.2
 
57
  (let ((i 0) x y z)
 
58
    (values
 
59
     (rassoc-if-not (progn (setf x (incf i)) #'identity)
 
60
                    (progn (setf y (incf i))
 
61
                           '((1 . a) (2 . b) (17) (4 . d)))
 
62
                    :key (progn (setf z (incf i)) #'null))
 
63
     i x y z))
 
64
  (1 . a) 3 1 2 3)
 
65
 
 
66
;;; Keyword tests
 
67
 
 
68
(deftest rassoc-if-not.allow-other-keys.1
 
69
  (rassoc-if-not #'identity '((1 . a) (2) (3 . c)) :bad t :allow-other-keys t)
 
70
  (2))
 
71
 
 
72
(deftest rassoc-if-not.allow-other-keys.2
 
73
  (rassoc-if-not #'values '((1 . a) (2) (3 . c)) :allow-other-keys t :bad t)
 
74
  (2))
 
75
 
 
76
(deftest rassoc-if-not.allow-other-keys.3
 
77
  (rassoc-if-not #'not '((1 . a) (2) (3 . c)) :allow-other-keys t :bad t
 
78
          :key 'not)
 
79
  (2))
 
80
 
 
81
(deftest rassoc-if-not.allow-other-keys.4
 
82
  (rassoc-if-not #'identity '((1 . a) (2) (3 . c)) :allow-other-keys t)
 
83
  (2))
 
84
 
 
85
(deftest rassoc-if-not.allow-other-keys.5
 
86
  (rassoc-if-not #'identity '((1 . a) (2) (3 . c)) :allow-other-keys nil)
 
87
  (2))
 
88
 
 
89
(deftest rassoc-if-not.allow-other-keys.6
 
90
  (rassoc-if-not #'identity '((1 . a) (2) (3 . c)) :allow-other-keys t
 
91
                 :allow-other-keys nil :bad t)
 
92
  (2))
 
93
 
 
94
(deftest rassoc-if-not.keywords.7
 
95
  (rassoc-if-not #'identity '((1 . a) (2) (3 . c)) :key #'not :key nil)
 
96
  (1 . a))
 
97
 
 
98
;;; Error tests
 
99
 
 
100
(deftest rassoc-if-not.error.1
 
101
  (signals-error (rassoc-if-not) program-error)
 
102
  t)
 
103
 
 
104
(deftest rassoc-if-not.error.2
 
105
  (signals-error (rassoc-if-not #'null) program-error)
 
106
  t)
 
107
 
 
108
(deftest rassoc-if-not.error.3
 
109
  (signals-error (rassoc-if-not #'null nil :bad t) program-error)
 
110
  t)
 
111
 
 
112
(deftest rassoc-if-not.error.4
 
113
  (signals-error (rassoc-if-not #'null nil :key) program-error)
 
114
  t)
 
115
 
 
116
(deftest rassoc-if-not.error.5
 
117
  (signals-error (rassoc-if-not #'null nil 1 1) program-error)
 
118
  t)
 
119
 
 
120
(deftest rassoc-if-not.error.6
 
121
  (signals-error (rassoc-if-not #'null nil :bad t :allow-other-keys nil) program-error)
 
122
  t)
 
123
 
 
124
(deftest rassoc-if-not.error.7
 
125
  (signals-error (rassoc-if-not #'cons '((a . b)(c . d))) program-error)
 
126
  t)
 
127
 
 
128
(deftest rassoc-if-not.error.8
 
129
  (signals-error (rassoc-if-not #'car '((a . b)(c . d))) type-error)
 
130
  t)
 
131
 
 
132
(deftest rassoc-if-not.error.9
 
133
  (signals-error (rassoc-if-not #'identity '((a . b)(c . d)) :key #'cons) program-error)
 
134
  t)
 
135
 
 
136
(deftest rassoc-if-not.error.10
 
137
  (signals-error (rassoc-if-not #'identity '((a . b)(c . d)) :key #'car) type-error)
 
138
  t)
 
139
 
 
140
(deftest rassoc-if-not.error.11
 
141
  (signals-error (rassoc-if-not #'identity '((a . b) . c)) type-error)
 
142
  t)