Commit | Line | Data |
---|---|---|
40339d6b KR |
1 | ;;;; hash.test --- test guile hashing -*- scheme -*- |
2 | ;;;; | |
87c08ac0 | 3 | ;;;; Copyright (C) 2004, 2005 Free Software Foundation, Inc. |
40339d6b KR |
4 | ;;;; |
5 | ;;;; This library is free software; you can redistribute it and/or | |
6 | ;;;; modify it under the terms of the GNU Lesser General Public | |
7 | ;;;; License as published by the Free Software Foundation; either | |
8 | ;;;; version 2.1 of the License, or (at your option) any later version. | |
9 | ;;;; | |
10 | ;;;; This library is distributed in the hope that it will be useful, | |
11 | ;;;; but WITHOUT ANY WARRANTY; without even the implied warranty of | |
12 | ;;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
13 | ;;;; Lesser General Public License for more details. | |
14 | ;;;; | |
15 | ;;;; You should have received a copy of the GNU Lesser General Public | |
16 | ;;;; License along with this library; if not, write to the Free Software | |
92205699 | 17 | ;;;; Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
40339d6b KR |
18 | |
19 | (define-module (test-suite test-numbers) | |
20 | #:use-module (test-suite lib) | |
21 | #:use-module (ice-9 documentation)) | |
22 | ||
23 | ;;; | |
24 | ;;; hash | |
25 | ;;; | |
26 | ||
27 | (with-test-prefix "hash" | |
28 | (pass-if (->bool (object-documentation hash))) | |
29 | (pass-if-exception "hash #t -1" exception:out-of-range | |
30 | (hash #t -1)) | |
31 | (pass-if-exception "hash #t 0" exception:out-of-range | |
32 | (hash #t 0)) | |
33 | (pass-if (= 0 (hash #t 1))) | |
34 | (pass-if (= 0 (hash #f 1))) | |
35 | (pass-if (= 0 (hash noop 1)))) | |
36 | ||
37 | ;;; | |
38 | ;;; hashv | |
39 | ;;; | |
40 | ||
41 | (with-test-prefix "hashv" | |
42 | (pass-if (->bool (object-documentation hashv))) | |
43 | (pass-if-exception "hashv #t -1" exception:out-of-range | |
44 | (hashv #t -1)) | |
45 | (pass-if-exception "hashv #t 0" exception:out-of-range | |
46 | (hashv #t 0)) | |
47 | (pass-if (= 0 (hashv #t 1))) | |
48 | (pass-if (= 0 (hashv #f 1))) | |
49 | (pass-if (= 0 (hashv noop 1)))) | |
50 | ||
51 | ;;; | |
52 | ;;; hashq | |
53 | ;;; | |
54 | ||
55 | (with-test-prefix "hashq" | |
56 | (pass-if (->bool (object-documentation hashq))) | |
57 | (pass-if-exception "hashq #t -1" exception:out-of-range | |
58 | (hashq #t -1)) | |
59 | (pass-if-exception "hashq #t 0" exception:out-of-range | |
60 | (hashq #t 0)) | |
61 | (pass-if (= 0 (hashq #t 1))) | |
62 | (pass-if (= 0 (hashq #f 1))) | |
63 | (pass-if (= 0 (hashq noop 1)))) | |
87c08ac0 KR |
64 | |
65 | ;;; | |
66 | ;;; hashx-remove! | |
67 | ;;; | |
68 | ||
69 | (with-test-prefix "hashx-remove!" | |
70 | (pass-if (->bool (object-documentation hashx-remove!))) | |
71 | ||
72 | (pass-if (let ((table (make-hash-table))) | |
73 | (hashx-set! hashq assq table 'x 123) | |
74 | (hashx-remove! hashq assq table 'x) | |
75 | (null? (hash-map->list noop table))))) |