reformat hash tests
svn: r14422
This commit is contained in:
parent
cb2c85956b
commit
50ec8211e2
|
@ -1926,22 +1926,15 @@
|
|||
hash-iterate-first hash-iterate-next
|
||||
hash-iterate-value hash-iterate-key
|
||||
hash-copy)
|
||||
(let ()
|
||||
(define-struct ax (b c)) ; opaque
|
||||
(define-struct a (b c) #:inspector (make-inspector))
|
||||
|
||||
(define save (let ([x null])
|
||||
(case-lambda
|
||||
[() x]
|
||||
[(a) (set! x (cons a x)) a])))
|
||||
|
||||
(define save
|
||||
(let ([x null]) (case-lambda [() x] [(a) (set! x (cons a x)) a])))
|
||||
(define an-ax (make-ax 1 2))
|
||||
|
||||
(let ([check-hash-tables
|
||||
(lambda (weak? reorder?)
|
||||
(let ([h1 (if weak?
|
||||
(make-weak-hasheq)
|
||||
(make-hasheq))]
|
||||
(define (check-hash-tables weak? reorder?)
|
||||
(let ([h1 (if weak? (make-weak-hasheq) (make-hasheq))]
|
||||
[l (list 1 2 3)])
|
||||
(test #t eq? (eq-hash-code l) (eq-hash-code l))
|
||||
(test #t eq? (eqv-hash-code l) (eqv-hash-code l))
|
||||
|
@ -1961,9 +1954,7 @@
|
|||
(test 1 hash-ref h1 l)
|
||||
(hash-remove! h1 l))
|
||||
|
||||
(let ([h1 (if weak?
|
||||
(make-weak-hasheqv)
|
||||
(make-hasheqv))]
|
||||
(let ([h1 (if weak? (make-weak-hasheqv) (make-hasheqv))]
|
||||
[n (expt 2 500)]
|
||||
[q (/ 1 2)]
|
||||
[s (make-string 2 #\q)])
|
||||
|
@ -1974,9 +1965,7 @@
|
|||
(test 'half hash-ref h1 (/ 1 (read (open-input-string "2"))))
|
||||
(test #f hash-ref h1 (make-string (read (open-input-string "2")) #\q) #f))
|
||||
|
||||
(let ([h1 (if weak?
|
||||
(make-weak-hash)
|
||||
(make-hash))]
|
||||
(let ([h1 (if weak? (make-weak-hash) (make-hash))]
|
||||
[l (list 1 2 3)]
|
||||
[v (vector 5 6 7)]
|
||||
[a (make-a 1 (make-a 2 3))]
|
||||
|
@ -2042,8 +2031,7 @@
|
|||
(test #t
|
||||
andmap
|
||||
(lambda (i)
|
||||
(and (member i
|
||||
(hash-map h1 (lambda (k v) (cons k v))))
|
||||
(and (member i (hash-map h1 (lambda (k v) (cons k v))))
|
||||
#t))
|
||||
`(((1 2 3) . list)
|
||||
((5 7) . another-list)
|
||||
|
@ -2065,16 +2053,13 @@
|
|||
(hash-for-each h1 (lambda (k v) (set! c (add1 c))))
|
||||
(test 12 'count c))
|
||||
;; return the hash table:
|
||||
h1))])
|
||||
h1))
|
||||
|
||||
(let ([check-tables-equal
|
||||
(lambda (mode t1 t2 weak?)
|
||||
(define (check-tables-equal mode t1 t2 weak?)
|
||||
(test #t equal? t1 t2)
|
||||
(test (equal-hash-code t1) equal-hash-code t2)
|
||||
(test #t equal? t1 (hash-copy t1))
|
||||
(let ([again (if weak?
|
||||
(make-weak-hash)
|
||||
(make-hash))])
|
||||
(let ([again (if weak? (make-weak-hash) (make-hash))])
|
||||
(let loop ([i (hash-iterate-first t1)])
|
||||
(when i
|
||||
(hash-set! again
|
||||
|
@ -2085,7 +2070,7 @@
|
|||
(let ([meta-ht (make-hash)])
|
||||
(hash-set! meta-ht t1 mode)
|
||||
(test mode hash-ref meta-ht t2 (lambda () #f)))
|
||||
(test (hash-count t1) hash-count t2))])
|
||||
(test (hash-count t1) hash-count t2))
|
||||
|
||||
(check-tables-equal 'the-norm-table
|
||||
(check-hash-tables #f #f)
|
||||
|
@ -2095,9 +2080,9 @@
|
|||
(check-tables-equal 'the-weak-table
|
||||
(check-hash-tables #t #f)
|
||||
(check-hash-tables #t #t)
|
||||
#t)))
|
||||
#t))
|
||||
|
||||
(save)))) ; prevents gcing of the ht-registered values
|
||||
(save)) ; prevents gcing of the ht-registered values
|
||||
|
||||
(hash-tests make-hash make-hasheq make-hasheqv
|
||||
make-weak-hash make-weak-hasheq make-weak-hasheqv
|
||||
|
|
Loading…
Reference in New Issue
Block a user