Fixing pr11196 and fixing bug in hash-eqv serialization
This commit is contained in:
parent
12fb39f5bd
commit
43d527818e
|
@ -309,7 +309,8 @@
|
|||
(list* 'h
|
||||
(if (immutable? v) '- '!)
|
||||
(append
|
||||
(if (not (hash-eq? v)) '(equal) null)
|
||||
(if (hash-equal? v) '(equal) null)
|
||||
(if (hash-eqv? v) '(eqv) null)
|
||||
(if (hash-weak? v) '(weak) null))
|
||||
(let ([loop (serial #t)])
|
||||
(hash-map v (lambda (k v)
|
||||
|
@ -342,7 +343,8 @@
|
|||
'b]
|
||||
[(hash? v)
|
||||
(cons 'h (append
|
||||
(if (not (hash-eq? v)) '(equal) null)
|
||||
(if (hash-equal? v) '(equal) null)
|
||||
(if (hash-eqv? v) '(eqv) null)
|
||||
(if (hash-weak? v) '(weak) null)))]
|
||||
[else
|
||||
;; A mutable prefab
|
||||
|
@ -395,13 +397,19 @@
|
|||
;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
|
||||
(define (make-hash/flags v)
|
||||
(cond
|
||||
[(null? v) (make-hasheq)]
|
||||
[(eq? (car v) 'equal)
|
||||
(if (null? (cdr v))
|
||||
(make-hash)
|
||||
(make-weak-hash))]
|
||||
[else (make-weak-hasheq)]))
|
||||
(if (null? v)
|
||||
(make-hasheq)
|
||||
(case (car v)
|
||||
[(equal)
|
||||
(if (null? (cdr v))
|
||||
(make-hash)
|
||||
(make-weak-hash))]
|
||||
[(eqv)
|
||||
(if (null? (cdr v))
|
||||
(make-hasheqv)
|
||||
(make-weak-hasheqv))]
|
||||
[(weak)
|
||||
(make-weak-hasheq)])))
|
||||
|
||||
(define-struct not-ready (shares fixup))
|
||||
|
||||
|
@ -470,7 +478,9 @@
|
|||
ht)
|
||||
(if (null? (caddr v))
|
||||
(make-immutable-hasheq al)
|
||||
(make-immutable-hash al))))]
|
||||
(if (eq? (caaddr v) 'equal)
|
||||
(make-immutable-hash al)
|
||||
(make-immutable-hasheqv al)))))]
|
||||
[(date) (apply make-date (map loop (cdr v)))]
|
||||
[(arity-at-least) (make-arity-at-least (loop (cdr v)))]
|
||||
[(mpi) (module-path-index-join (loop (cadr v))
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
#lang racket/base
|
||||
(require (for-syntax racket/base)
|
||||
racket/serialize
|
||||
racket/pretty)
|
||||
|
||||
(provide set seteq seteqv
|
||||
|
@ -13,7 +14,7 @@
|
|||
for/set for/seteq for/seteqv
|
||||
for*/set for*/seteq for*/seteqv)
|
||||
|
||||
(define-struct set (ht)
|
||||
(define-serializable-struct set (ht)
|
||||
#:omit-define-syntaxes
|
||||
#:property prop:custom-print-quotable 'never
|
||||
#:property prop:custom-write
|
||||
|
|
|
@ -47,7 +47,7 @@ The following kinds of values are serializable:
|
|||
@tech{unreadable symbols}, strings, byte strings, paths (for a
|
||||
specific convention), @|void-const|, and the empty list;}
|
||||
|
||||
@item{pairs, mutable pairs, vectors, boxes, and hash tables;}
|
||||
@item{pairs, mutable pairs, vectors, boxes, hash tables, and sets;}
|
||||
|
||||
@item{@scheme[date] and @scheme[arity-at-least] structures; and}
|
||||
|
||||
|
|
|
@ -65,6 +65,7 @@
|
|||
(hash-set! ht v1 v2)
|
||||
(and (eq? (immutable? v1) (immutable? v2))
|
||||
(eq? (hash-eq? v1) (hash-eq? v2))
|
||||
(eq? (hash-eqv? v1) (hash-eqv? v2))
|
||||
(eq? (hash-weak? v1) (hash-weak? v2))
|
||||
(= (hash-count v1) (hash-count v2))
|
||||
(let ([ok? #t])
|
||||
|
@ -124,14 +125,21 @@
|
|||
(test-ser (seconds->date (current-seconds)))
|
||||
(test-ser (procedure-arity (lambda (x . y) 10)))
|
||||
(test-ser (make-immutable-hasheq '((1 . a) (2 . b))))
|
||||
(test-ser (make-immutable-hasheqv '((1 . a) (2 . b))))
|
||||
(test-ser (make-immutable-hash '(("x" . a) ("y" . b))))
|
||||
(test-ser (mk-ht make-hasheq))
|
||||
(test-ser (mk-ht make-hasheqv))
|
||||
(test-ser (mk-ht make-hash))
|
||||
(test-ser (mk-ht make-weak-hasheq))
|
||||
(test-ser (mk-ht make-weak-hasheqv))
|
||||
(test-ser (mk-ht make-weak-hash))
|
||||
(test-ser #s(a 0 1 2))
|
||||
(test-ser #s((a q 2) 0 1 2))
|
||||
|
||||
(test-ser (set 'set 0 1 2))
|
||||
(test-ser (seteqv 'seteqv 0 1 2))
|
||||
(test-ser (seteq 'seteq 0 1 2))
|
||||
|
||||
(test-ser '(1))
|
||||
(test-ser '#(1))
|
||||
(test-ser '#&1)
|
||||
|
|
Loading…
Reference in New Issue
Block a user