Mercurial > hg > xemacs-beta
comparison tests/automated/hash-table-tests.el @ 5633:49c36ed998b6
No longer use the obsolete function names, hash-table-tests.el
tests/ChangeLog addition:
2011-12-30 Aidan Kehoe <kehoea@parhasard.net>
* automated/hash-table-tests.el:
No longer use the obsolete function names in the tests, now
they've been removed from cl.el.
author | Aidan Kehoe <kehoea@parhasard.net> |
---|---|
date | Fri, 30 Dec 2011 16:39:14 +0000 |
parents | 071b810ceb18 |
children |
comparison
equal
deleted
inserted
replaced
5632:bd80d9103fc8 | 5633:49c36ed998b6 |
---|---|
53 (Assert (<= size (hash-table-size ht))) | 53 (Assert (<= size (hash-table-size ht))) |
54 (Assert (eql rehash-size (hash-table-rehash-size ht))) | 54 (Assert (eql rehash-size (hash-table-rehash-size ht))) |
55 (Assert (eql rehash-threshold (hash-table-rehash-threshold ht))) | 55 (Assert (eql rehash-threshold (hash-table-rehash-threshold ht))) |
56 (Assert (eq weakness (hash-table-weakness ht)))))))))) | 56 (Assert (eq weakness (hash-table-weakness ht)))))))))) |
57 | 57 |
58 (loop for (fun weakness) in '((make-hashtable nil) | |
59 (make-weak-hashtable key-and-value) | |
60 (make-key-weak-hashtable key) | |
61 (make-value-weak-hashtable value)) | |
62 do (Assert (eq weakness (hash-table-weakness (funcall fun 10))))) | |
63 | |
64 (loop for (type weakness) in '((non-weak nil) | 58 (loop for (type weakness) in '((non-weak nil) |
65 (weak key-and-value) | 59 (weak key-and-value) |
66 (key-weak key) | 60 (key-weak key) |
67 (value-weak value)) | 61 (value-weak value)) |
68 do (Assert (equal (make-hash-table :type type) | 62 do (Assert (equal (make-hash-table :type type) |
71 (Assert (not (equal (make-hash-table :weakness nil) | 65 (Assert (not (equal (make-hash-table :weakness nil) |
72 (make-hash-table :weakness t)))) | 66 (make-hash-table :weakness t)))) |
73 | 67 |
74 (let ((ht (make-hash-table :size 20 :rehash-threshold .75 :test 'eq)) | 68 (let ((ht (make-hash-table :size 20 :rehash-threshold .75 :test 'eq)) |
75 (size 80)) | 69 (size 80)) |
76 (Assert (hashtablep ht)) | |
77 (Assert (hash-table-p ht)) | 70 (Assert (hash-table-p ht)) |
78 (Assert (eq 'eq (hash-table-test ht))) | 71 (Assert (eq 'eq (hash-table-test ht))) |
79 (Assert (eq 'non-weak (hash-table-type ht))) | 72 (Assert (eq 'non-weak (hash-table-type ht))) |
80 (Assert (eq 'non-weak (hashtable-type ht))) | |
81 (Assert (eq 'nil (hash-table-weakness ht))) | 73 (Assert (eq 'nil (hash-table-weakness ht))) |
82 (dotimes (j size) | 74 (dotimes (j size) |
83 (puthash j (- j) ht) | 75 (puthash j (- j) ht) |
84 (Assert (eq (gethash j ht) (- j))) | 76 (Assert (eq (gethash j ht) (- j))) |
85 (Assert (= (hash-table-count ht) (1+ j))) | 77 (Assert (= (hash-table-count ht) (1+ j))) |
86 (Assert (= (hashtable-fullness ht) (hash-table-count ht))) | |
87 (puthash j j ht) | 78 (puthash j j ht) |
88 (Assert (eq (gethash j ht 'foo) j)) | 79 (Assert (eq (gethash j ht 'foo) j)) |
89 (Assert (= (hash-table-count ht) (1+ j))) | 80 (Assert (= (hash-table-count ht) (1+ j))) |
90 (setf (gethash j ht) (- j)) | 81 (setf (gethash j ht) (- j)) |
91 (Assert (eq (gethash j ht) (- j))) | 82 (Assert (eq (gethash j ht) (- j))) |
111 (Assert (eq (gethash j ht 'foo) 'foo)) | 102 (Assert (eq (gethash j ht 'foo) 'foo)) |
112 (Assert (= (hash-table-count ht) (decf count)))))) | 103 (Assert (= (hash-table-count ht) (decf count)))))) |
113 | 104 |
114 (let ((ht (make-hash-table :size 30 :rehash-threshold .25 :test 'equal)) | 105 (let ((ht (make-hash-table :size 30 :rehash-threshold .25 :test 'equal)) |
115 (size 70)) | 106 (size 70)) |
116 (Assert (hashtablep ht)) | |
117 (Assert (hash-table-p ht)) | 107 (Assert (hash-table-p ht)) |
118 (Assert (>= (hash-table-size ht) (/ 30 .25))) | 108 (Assert (>= (hash-table-size ht) (/ 30 .25))) |
119 (Assert (eql .25 (hash-table-rehash-threshold ht))) | 109 (Assert (eql .25 (hash-table-rehash-threshold ht))) |
120 (Assert (eq 'equal (hash-table-test ht))) | 110 (Assert (eq 'equal (hash-table-test ht))) |
121 (Assert (eq (hash-table-test ht) (hashtable-test-function ht))) | |
122 (Assert (eq 'non-weak (hash-table-type ht))) | 111 (Assert (eq 'non-weak (hash-table-type ht))) |
123 (dotimes (j size) | 112 (dotimes (j size) |
124 (puthash (int-to-string j) (- j) ht) | 113 (puthash (int-to-string j) (- j) ht) |
125 (Assert (eq (gethash (int-to-string j) ht) (- j))) | 114 (Assert (eq (gethash (int-to-string j) ht) (- j))) |
126 (Assert (= (hash-table-count ht) (1+ j))) | 115 (Assert (= (hash-table-count ht) (1+ j))) |
165 (dotimes (j iterations) | 154 (dotimes (j iterations) |
166 (puthash (+ one 0.0) t ht) | 155 (puthash (+ one 0.0) t ht) |
167 (puthash (+ two 0.0) t ht) | 156 (puthash (+ two 0.0) t ht) |
168 (puthash (cons 1 2) t ht) | 157 (puthash (cons 1 2) t ht) |
169 (puthash (cons 3 4) t ht)) | 158 (puthash (cons 3 4) t ht)) |
170 (Assert (eq (hashtable-test-function ht) 'eq)) | |
171 (Assert (eq (hash-table-test ht) 'eq)) | 159 (Assert (eq (hash-table-test ht) 'eq)) |
172 (Assert (= (* iterations 4) (hash-table-count ht))) | 160 (Assert (= (* iterations 4) (hash-table-count ht))) |
173 (Assert (eq nil (gethash 1.0 ht))) | 161 (Assert (eq nil (gethash 1.0 ht))) |
174 (Assert (eq nil (gethash '(1 . 2) ht))) | 162 (Assert (eq nil (gethash '(1 . 2) ht))) |
175 (check-copy ht) | 163 (check-copy ht) |
179 (dotimes (j iterations) | 167 (dotimes (j iterations) |
180 (puthash (+ one 0.0) t ht) | 168 (puthash (+ one 0.0) t ht) |
181 (puthash (+ two 0.0) t ht) | 169 (puthash (+ two 0.0) t ht) |
182 (puthash (cons 1 2) t ht) | 170 (puthash (cons 1 2) t ht) |
183 (puthash (cons 3 4) t ht)) | 171 (puthash (cons 3 4) t ht)) |
184 (Assert (eq (hashtable-test-function ht) 'eql)) | |
185 (Assert (eq (hash-table-test ht) 'eql)) | 172 (Assert (eq (hash-table-test ht) 'eql)) |
186 (Assert (= (+ 2 (* 2 iterations)) (hash-table-count ht))) | 173 (Assert (= (+ 2 (* 2 iterations)) (hash-table-count ht))) |
187 (Assert (eq t (gethash 1.0 ht))) | 174 (Assert (eq t (gethash 1.0 ht))) |
188 (Assert (eq nil (gethash '(1 . 2) ht))) | 175 (Assert (eq nil (gethash '(1 . 2) ht))) |
189 (check-copy ht) | 176 (check-copy ht) |
193 (dotimes (j iterations) | 180 (dotimes (j iterations) |
194 (puthash (+ one 0.0) t ht) | 181 (puthash (+ one 0.0) t ht) |
195 (puthash (+ two 0.0) t ht) | 182 (puthash (+ two 0.0) t ht) |
196 (puthash (cons 1 2) t ht) | 183 (puthash (cons 1 2) t ht) |
197 (puthash (cons 3 4) t ht)) | 184 (puthash (cons 3 4) t ht)) |
198 (Assert (eq (hashtable-test-function ht) 'equal)) | |
199 (Assert (eq (hash-table-test ht) 'equal)) | 185 (Assert (eq (hash-table-test ht) 'equal)) |
200 (Assert (= 4 (hash-table-count ht))) | 186 (Assert (= 4 (hash-table-count ht))) |
201 (Assert (eq t (gethash 1.0 ht))) | 187 (Assert (eq t (gethash 1.0 ht))) |
202 (Assert (eq t (gethash '(1 . 2) ht))) | 188 (Assert (eq t (gethash '(1 . 2) ht))) |
203 (check-copy ht) | 189 (check-copy ht) |
212 (puthash (cons 1.0 2.0) (gensym) ht) | 198 (puthash (cons 1.0 2.0) (gensym) ht) |
213 ;; Override the previous entry. | 199 ;; Override the previous entry. |
214 (puthash (cons 1 2) t ht) | 200 (puthash (cons 1 2) t ht) |
215 (puthash (cons 3.0 4.0) (gensym) ht) | 201 (puthash (cons 3.0 4.0) (gensym) ht) |
216 (puthash (cons 3 4) t ht)) | 202 (puthash (cons 3 4) t ht)) |
217 (Assert (eq (hashtable-test-function ht) 'equalp)) | |
218 (Assert (eq (hash-table-test ht) 'equalp)) | 203 (Assert (eq (hash-table-test ht) 'equalp)) |
219 (Assert (= 4 (hash-table-count ht))) | 204 (Assert (= 4 (hash-table-count ht))) |
220 (Assert (eq t (gethash 1.0 ht))) | 205 (Assert (eq t (gethash 1.0 ht))) |
221 (Assert (eq t (gethash '(1 . 2) ht))) | 206 (Assert (eq t (gethash '(1 . 2) ht))) |
222 (check-copy ht) | 207 (check-copy ht) |