* hashtab.c (scm_hash_fn_create_handle_x): If supplied assoc_fn
[bpt/guile.git] / test-suite / tests / hash.test
CommitLineData
40339d6b
KR
1;;;; hash.test --- test guile hashing -*- scheme -*-
2;;;;
6e7d5622 3;;;; Copyright (C) 2004, 2005, 2006 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;;;
87c08ac0
KR
68(with-test-prefix "hashx-remove!"
69 (pass-if (->bool (object-documentation hashx-remove!)))
70
71 (pass-if (let ((table (make-hash-table)))
72 (hashx-set! hashq assq table 'x 123)
73 (hashx-remove! hashq assq table 'x)
74 (null? (hash-map->list noop table)))))
15bd90ea
NJ
75
76;;;
77;;; hashx
78;;;
79
80(with-test-prefix "hashx"
81 (pass-if-exception
82 "hashx-set! (lambda (k s) 1) (lambda (k al) #t) table 'foo 'bar"
83 exception:wrong-type-arg
84 (hashx-set! (lambda (k s) 1) (lambda (k al) #t) (make-hash-table) 'foo 'bar))
85 )