summaryrefslogtreecommitdiffstats
path: root/srfi-225-test.scm
diff options
context:
space:
mode:
authorGravatar John Cowan 2021-11-23 14:21:56 -0500
committerGravatar John Cowan 2021-11-23 14:21:56 -0500
commita6fbdb2cfe97b41c4479170d80934f218a1553a8 (patch)
treeb538484cf28d6b09b0cf021529302fc6b4273697 /srfi-225-test.scm
parentimproved rationale (diff)
dto and find-update
Diffstat (limited to 'srfi-225-test.scm')
-rw-r--r--srfi-225-test.scm396
1 files changed, 198 insertions, 198 deletions
diff --git a/srfi-225-test.scm b/srfi-225-test.scm
index 3630605..1ef4231 100644
--- a/srfi-225-test.scm
+++ b/srfi-225-test.scm
@@ -48,19 +48,19 @@
(else
(import (srfi 64))))
-;; returns new wrapper dtd
-;; which counts how often each dtd's method was called
+;; returns new wrapper dto
+;; which counts how often each dto's method was called
;; verify that all functions were tested
-(define (wrap-dtd dtd)
+(define (wrap-dto dto)
(define proc-count (+ 1 dict-adjoin-accumulator-id))
(define counter (make-vector proc-count 0))
- (define wrapper-dtd-args
+ (define wrapper-dto-args
(let loop ((indexes (iota proc-count))
(args '()))
(if (null? indexes)
args
(let* ((index (car indexes))
- (real-proc (dtd-ref dtd index))
+ (real-proc (dto-ref dto index))
(wrapper-proc (lambda args
(vector-set! counter index (+ 1 (vector-ref counter index)))
(apply real-proc args))))
@@ -68,7 +68,7 @@
(append (list index wrapper-proc)
args))))))
(values
- (apply make-dtd wrapper-dtd-args)
+ (apply make-dto wrapper-dto-args)
counter))
(define (test-for-each expect-success for-each-proc expected-keys)
@@ -89,28 +89,28 @@
expected-keys)))
lst))))))
-(define (do-test real-dtd alist->dict comparator mutable?)
+(define (do-test real-dto alist->dict comparator mutable?)
(define-values
- (dtd counter)
- (wrap-dtd real-dtd))
+ (dto counter)
+ (wrap-dto real-dto))
(test-group
"dictionary?"
- (test-assert (not (dictionary? dtd 'foo)))
- (test-assert (dictionary? dtd (alist->dict '())))
- (test-assert (dictionary? dtd (alist->dict '((a . b))))))
+ (test-assert (not (dictionary? dto 'foo)))
+ (test-assert (dictionary? dto (alist->dict '())))
+ (test-assert (dictionary? dto (alist->dict '((a . b))))))
(test-group
"dict-empty?"
- (test-assert (dict-empty? dtd (alist->dict '())))
- (test-assert (not (dict-empty? dtd (alist->dict '((a . b)))))))
+ (test-assert (dict-empty? dto (alist->dict '())))
+ (test-assert (not (dict-empty? dto (alist->dict '((a . b)))))))
(test-group
"dict-contains?"
- (test-assert (not (dict-contains? dtd (alist->dict '()) 'a)))
- (test-assert (not (dict-contains? dtd (alist->dict '((b . c))) 'a)))
- (test-assert (dict-contains? dtd (alist->dict '((a . b))) 'a)))
+ (test-assert (not (dict-contains? dto (alist->dict '()) 'a)))
+ (test-assert (not (dict-contains? dto (alist->dict '((b . c))) 'a)))
+ (test-assert (dict-contains? dto (alist->dict '((a . b))) 'a)))
(test-group
"dict=?"
@@ -119,108 +119,108 @@
(define dict3 (alist->dict '((a . 1))))
(define dict4 (alist->dict '((a . 2) (b . 2))))
- (test-assert (dict=? dtd = dict1 dict2))
- (test-assert (not (dict=? dtd = dict1 dict3)))
- (test-assert (not (dict=? dtd = dict3 dict1)))
- (test-assert (not (dict=? dtd = dict1 dict4)))
- (test-assert (not (dict=? dtd = dict4 dict1))))
+ (test-assert (dict=? dto = dict1 dict2))
+ (test-assert (not (dict=? dto = dict1 dict3)))
+ (test-assert (not (dict=? dto = dict3 dict1)))
+ (test-assert (not (dict=? dto = dict1 dict4)))
+ (test-assert (not (dict=? dto = dict4 dict1))))
(test-group
"dict-ref"
- (test-assert (dict-ref dtd (alist->dict '((a . b))) 'a (lambda () #f) (lambda (x) #t)))
- (test-assert (dict-ref dtd (alist->dict '((a . b))) 'b (lambda () #t) (lambda (x) #f))))
+ (test-assert (dict-ref dto (alist->dict '((a . b))) 'a (lambda () #f) (lambda (x) #t)))
+ (test-assert (dict-ref dto (alist->dict '((a . b))) 'b (lambda () #t) (lambda (x) #f))))
(test-group
"dict-ref/default"
- (test-equal (dict-ref/default dtd (alist->dict '((a . b))) 'a 'c) 'b)
- (test-equal (dict-ref/default dtd (alist->dict '((a* . b))) 'a 'c) 'c))
+ (test-equal (dict-ref/default dto (alist->dict '((a . b))) 'a 'c) 'b)
+ (test-equal (dict-ref/default dto (alist->dict '((a* . b))) 'a 'c) 'c))
(when mutable?
(test-skip 1))
(test-group
"dict-set"
(define dict-original (alist->dict '((a . b))))
- (define d (dict-set dtd dict-original 'a 'c 'a2 'b2))
- (test-equal 'c (dict-ref dtd d 'a ))
- (test-equal 'b2 (dict-ref dtd d 'a2))
- (test-equal 'b (dict-ref dtd dict-original' a))
- (test-equal #f (dict-ref/default dtd dict-original 'a2 #f)))
+ (define d (dict-set dto dict-original 'a 'c 'a2 'b2))
+ (test-equal 'c (dict-ref dto d 'a ))
+ (test-equal 'b2 (dict-ref dto d 'a2))
+ (test-equal 'b (dict-ref dto dict-original' a))
+ (test-equal #f (dict-ref/default dto dict-original 'a2 #f)))
(unless mutable?
(test-skip 1))
(test-group
"dict-set!"
- (define d (dict-set! dtd (alist->dict '((a . b))) 'a 'c 'a2 'b2))
- (test-equal 'c (dict-ref dtd d 'a ))
- (test-equal 'b2 (dict-ref dtd d 'a2)))
+ (define d (dict-set! dto (alist->dict '((a . b))) 'a 'c 'a2 'b2))
+ (test-equal 'c (dict-ref dto d 'a ))
+ (test-equal 'b2 (dict-ref dto d 'a2)))
(when mutable?
(test-skip 1))
(test-group
"dict-adjoin"
(define dict-original (alist->dict '((a . b))))
- (define d (dict-adjoin dtd dict-original 'a 'c 'a2 'b2))
- (test-equal 'b (dict-ref dtd d 'a))
- (test-equal 'b2 (dict-ref dtd d 'a2))
- (test-equal #f (dict-ref/default dtd dict-original 'a2 #f)))
+ (define d (dict-adjoin dto dict-original 'a 'c 'a2 'b2))
+ (test-equal 'b (dict-ref dto d 'a))
+ (test-equal 'b2 (dict-ref dto d 'a2))
+ (test-equal #f (dict-ref/default dto dict-original 'a2 #f)))
(unless mutable?
(test-skip 1))
(test-group
"dict-adjoin!"
- (define d (dict-adjoin! dtd (alist->dict '((a . b))) 'a 'c 'a2 'b2))
- (test-equal 'b (dict-ref dtd d 'a))
- (test-equal 'b2 (dict-ref dtd d 'a2)))
+ (define d (dict-adjoin! dto (alist->dict '((a . b))) 'a 'c 'a2 'b2))
+ (test-equal 'b (dict-ref dto d 'a))
+ (test-equal 'b2 (dict-ref dto d 'a2)))
(when mutable?
(test-skip 1))
(test-group
"dict-delete"
(define dict-original (alist->dict '((a . b) (c . d))))
- (define d (dict-delete dtd dict-original 'a 'b))
- (test-equal (dict->alist dtd d) '((c . d)))
- (test-equal 'b (dict-ref dtd dict-original 'a)))
+ (define d (dict-delete dto dict-original 'a 'b))
+ (test-equal (dict->alist dto d) '((c . d)))
+ (test-equal 'b (dict-ref dto dict-original 'a)))
(unless mutable?
(test-skip 1))
(test-group
"dict-delete!"
- (define d (dict-delete! dtd (alist->dict '((a . b) (c . d))) 'a 'b))
- (test-equal (dict->alist dtd d) '((c . d))))
+ (define d (dict-delete! dto (alist->dict '((a . b) (c . d))) 'a 'b))
+ (test-equal (dict->alist dto d) '((c . d))))
(when mutable?
(test-skip 1))
(test-group
"dict-delete-all"
(define dict-original (alist->dict '((a . b) (c . d))))
- (define d (dict-delete-all dtd dict-original '(a b)))
- (test-equal (dict->alist dtd d) '((c . d)))
- (test-equal 'b (dict-ref dtd dict-original 'a)))
+ (define d (dict-delete-all dto dict-original '(a b)))
+ (test-equal (dict->alist dto d) '((c . d)))
+ (test-equal 'b (dict-ref dto dict-original 'a)))
(unless mutable?
(test-skip 1))
(test-group
"dict-delete-all!"
- (define d (dict-delete-all! dtd (alist->dict '((a . b) (c . d))) '(a b)))
- (test-equal (dict->alist dtd d) '((c . d))))
+ (define d (dict-delete-all! dto (alist->dict '((a . b) (c . d))) '(a b)))
+ (test-equal (dict->alist dto d) '((c . d))))
(when mutable?
(test-skip 1))
(test-group
"dict-replace"
(define dict-original (alist->dict '((a . b) (c . d))))
- (define d (dict-replace dtd dict-original 'a 'b2))
- (test-equal 'b2 (dict-ref dtd d 'a))
- (test-equal 'd (dict-ref dtd d 'c))
- (test-equal 'b (dict-ref dtd dict-original 'a)))
+ (define d (dict-replace dto dict-original 'a 'b2))
+ (test-equal 'b2 (dict-ref dto d 'a))
+ (test-equal 'd (dict-ref dto d 'c))
+ (test-equal 'b (dict-ref dto dict-original 'a)))
(unless mutable?
(test-skip 1))
(test-group
"dict-replace!"
- (define d (dict-replace! dtd (alist->dict '((a . b) (c . d))) 'a 'b2))
- (test-equal 'b2 (dict-ref dtd d 'a))
- (test-equal 'd (dict-ref dtd d 'c)))
+ (define d (dict-replace! dto (alist->dict '((a . b) (c . d))) 'a 'b2))
+ (test-equal 'b2 (dict-ref dto d 'a))
+ (test-equal 'd (dict-ref dto d 'c)))
(when mutable?
(test-skip 1))
@@ -230,19 +230,19 @@
(let ()
(define-values
(d value)
- (dict-intern dtd (alist->dict '((a . b))) 'a (lambda () 'd)))
- (test-equal 'b (dict-ref dtd d 'a))
+ (dict-intern dto (alist->dict '((a . b))) 'a (lambda () 'd)))
+ (test-equal 'b (dict-ref dto d 'a))
(test-equal 'b value))
;; intern missing
(let ()
(define dict-original (alist->dict '((a . b))))
(define-values
(d value)
- (dict-intern dtd dict-original 'c (lambda () 'd)))
- (test-equal 'b (dict-ref dtd d 'a))
- (test-equal 'd (dict-ref dtd d 'c))
+ (dict-intern dto dict-original 'c (lambda () 'd)))
+ (test-equal 'b (dict-ref dto d 'a))
+ (test-equal 'd (dict-ref dto d 'c))
(test-equal 'd value)
- (test-equal #f (dict-ref/default dtd dict-original 'c #f))))
+ (test-equal #f (dict-ref/default dto dict-original 'c #f))))
(unless mutable?
(test-skip 1))
@@ -252,16 +252,16 @@
(let ()
(define-values
(d value)
- (dict-intern! dtd (alist->dict '((a . b))) 'a (lambda () 'd)))
- (test-equal 'b (dict-ref dtd d 'a))
+ (dict-intern! dto (alist->dict '((a . b))) 'a (lambda () 'd)))
+ (test-equal 'b (dict-ref dto d 'a))
(test-equal 'b value))
;; intern missing
(let ()
(define-values
(d value)
- (dict-intern! dtd (alist->dict '((a . b))) 'c (lambda () 'd)))
- (test-equal 'b (dict-ref dtd d 'a))
- (test-equal 'd (dict-ref dtd d 'c))
+ (dict-intern! dto (alist->dict '((a . b))) 'c (lambda () 'd)))
+ (test-equal 'b (dict-ref dto d 'a))
+ (test-equal 'd (dict-ref dto d 'c))
(test-equal 'd value)))
(when mutable?
@@ -271,22 +271,22 @@
;; update existing
(define dict-original (alist->dict '((a . "b"))))
(let ()
- (define d (dict-update dtd dict-original 'a
+ (define d (dict-update dto dict-original 'a
(lambda (value)
(string-append value "2"))
error
(lambda (x) (string-append x "1"))))
- (test-equal "b12" (dict-ref dtd d 'a))
- (test-equal "b" (dict-ref dtd dict-original 'a)))
+ (test-equal "b12" (dict-ref dto d 'a))
+ (test-equal "b" (dict-ref dto dict-original 'a)))
;; update missing
(let ()
- (define d (dict-update dtd dict-original 'c
+ (define d (dict-update dto dict-original 'c
(lambda (value)
(string-append value "2"))
(lambda () "d1")
(lambda (x) (string-append x "1"))))
- (test-equal "d12" (dict-ref dtd d 'c))
- (test-equal #f (dict-ref/default dtd dict-original 'c #f))))
+ (test-equal "d12" (dict-ref dto d 'c))
+ (test-equal #f (dict-ref/default dto dict-original 'c #f))))
(unless mutable?
(test-skip 1))
@@ -294,20 +294,20 @@
"dict-update!"
;; update existing
(let ()
- (define d (dict-update! dtd (alist->dict '((a . "b"))) 'a
+ (define d (dict-update! dto (alist->dict '((a . "b"))) 'a
(lambda (value)
(string-append value "2"))
error
(lambda (x) (string-append x "1"))))
- (test-equal "b12" (dict-ref dtd d 'a)))
+ (test-equal "b12" (dict-ref dto d 'a)))
;; update missing
(let ()
- (define d (dict-update! dtd (alist->dict '((a . "b"))) 'c
+ (define d (dict-update! dto (alist->dict '((a . "b"))) 'c
(lambda (value)
(string-append value "2"))
(lambda () "d1")
(lambda (x) (string-append x "1"))))
- (test-equal "d12" (dict-ref dtd d 'c))))
+ (test-equal "d12" (dict-ref dto d 'c))))
(when mutable?
(test-skip 1))
@@ -316,21 +316,21 @@
;; update existing
(define dict-original (alist->dict '((a . "b"))))
(let ()
- (define d (dict-update/default dtd dict-original 'a
+ (define d (dict-update/default dto dict-original 'a
(lambda (value)
(string-append value "2"))
"d1"))
- (test-equal "b2" (dict-ref dtd d 'a))
- (test-equal "b" (dict-ref dtd dict-original 'a)))
+ (test-equal "b2" (dict-ref dto d 'a))
+ (test-equal "b" (dict-ref dto dict-original 'a)))
;; update missing
(let ()
- (define d (dict-update/default dtd dict-original 'c
+ (define d (dict-update/default dto dict-original 'c
(lambda (value)
(string-append value "2"))
"d1"))
- (test-equal "d12" (dict-ref dtd d 'c))
- (test-equal #f (dict-ref/default dtd dict-original 'c #f))))
+ (test-equal "d12" (dict-ref dto d 'c))
+ (test-equal #f (dict-ref/default dto dict-original 'c #f))))
(unless mutable?
(test-skip 1))
@@ -338,19 +338,19 @@
"dict-update/default!"
;; update existing
(let ()
- (define d (dict-update/default! dtd (alist->dict '((a . "b"))) 'a
+ (define d (dict-update/default! dto (alist->dict '((a . "b"))) 'a
(lambda (value)
(string-append value "2"))
"d1"))
- (test-equal "b2" (dict-ref dtd d 'a)))
+ (test-equal "b2" (dict-ref dto d 'a)))
;; update missing
(let ()
- (define d (dict-update/default! dtd (alist->dict '((a . "b"))) 'c
+ (define d (dict-update/default! dto (alist->dict '((a . "b"))) 'c
(lambda (value)
(string-append value "2"))
"d1"))
- (test-equal "d12" (dict-ref dtd d 'c))))
+ (test-equal "d12" (dict-ref dto d 'c))))
(when mutable?
(test-skip 1))
@@ -359,18 +359,18 @@
(define dict-original (alist->dict '((a . b) (c . d))))
(define-values
(new-dict key value)
- (dict-pop dtd dict-original))
+ (dict-pop dto dict-original))
(test-assert
(or
- (and (equal? (dict->alist dtd new-dict) '((c . d)))
+ (and (equal? (dict->alist dto new-dict) '((c . d)))
(equal? key 'a)
(equal? value 'b))
- (and (equal? (dict->alist dtd new-dict) '((a . b)))
+ (and (equal? (dict->alist dto new-dict) '((a . b)))
(equal? key 'c)
(equal? value 'd))))
- (test-assert 'b (dict-ref dtd dict-original 'a))
- (test-assert 'd (dict-ref dtd dict-original 'c)))
+ (test-assert 'b (dict-ref dto dict-original 'a))
+ (test-assert 'd (dict-ref dto dict-original 'c)))
(unless mutable?
(test-skip 1))
@@ -378,14 +378,14 @@
"dict-pop!"
(define-values
(new-dict key value)
- (dict-pop! dtd (alist->dict '((a . b) (c . d)))))
+ (dict-pop! dto (alist->dict '((a . b) (c . d)))))
(test-assert
(or
- (and (equal? (dict->alist dtd new-dict) '((c . d)))
+ (and (equal? (dict->alist dto new-dict) '((c . d)))
(equal? key 'a)
(equal? value 'b))
- (and (equal? (dict->alist dtd new-dict) '((a . b)))
+ (and (equal? (dict->alist dto new-dict) '((a . b)))
(equal? key 'c)
(equal? value 'd)))))
@@ -394,25 +394,25 @@
(test-group
"dict-map"
(define dict-original (alist->dict '((a . "a") (b . "b"))))
- (define d (dict-map dtd
+ (define d (dict-map dto
(lambda (key value)
(string-append value "2"))
dict-original))
- (test-equal "a2" (dict-ref dtd d 'a))
- (test-equal "b2" (dict-ref dtd d 'b))
- (test-equal "a" (dict-ref dtd dict-original 'a))
- (test-equal "b" (dict-ref dtd dict-original 'b)))
+ (test-equal "a2" (dict-ref dto d 'a))
+ (test-equal "b2" (dict-ref dto d 'b))
+ (test-equal "a" (dict-ref dto dict-original 'a))
+ (test-equal "b" (dict-ref dto dict-original 'b)))
(unless mutable?
(test-skip 1))
(test-group
"dict-map!"
- (define d (dict-map! dtd
+ (define d (dict-map! dto
(lambda (key value)
(string-append value "2"))
(alist->dict '((a . "a") (b . "b")))))
- (test-equal "a2" (dict-ref dtd d 'a))
- (test-equal "b2" (dict-ref dtd d 'b)))
+ (test-equal "a2" (dict-ref dto d 'a))
+ (test-equal "b2" (dict-ref dto d 'b)))
(when mutable?
(test-skip 1))
@@ -420,142 +420,142 @@
"dict-filter"
(define dict-original (alist->dict '((a . b) (c . d))))
- (define d (dict-filter dtd
+ (define d (dict-filter dto
(lambda (key value)
(equal? value 'b))
dict-original))
- (test-equal '((a . b)) (dict->alist dtd d))
- (test-equal 'd (dict-ref dtd dict-original 'c)))
+ (test-equal '((a . b)) (dict->alist dto d))
+ (test-equal 'd (dict-ref dto dict-original 'c)))
(unless mutable?
(test-skip 1))
(test-group
"dict-filter!"
- (define d (dict-filter! dtd
+ (define d (dict-filter! dto
(lambda (key value)
(equal? value 'b))
(alist->dict '((a . b) (c . d)))))
- (test-equal '((a . b)) (dict->alist dtd d)))
+ (test-equal '((a . b)) (dict->alist dto d)))
(when mutable?
(test-skip 1))
(test-group
"dict-remove"
(define dict-original (alist->dict '((a . b) (c . d))))
- (define d (dict-remove dtd
+ (define d (dict-remove dto
(lambda (key value)
(equal? value 'b))
dict-original))
- (test-equal '((c . d)) (dict->alist dtd d))
- (test-equal 'b (dict-ref dtd dict-original 'a)))
+ (test-equal '((c . d)) (dict->alist dto d))
+ (test-equal 'b (dict-ref dto dict-original 'a)))
(unless mutable?
(test-skip 1))
(test-group
"dict-remove!"
- (define d (dict-remove! dtd
+ (define d (dict-remove! dto
(lambda (key value)
(equal? value 'b))
(alist->dict '((a . b) (c . d)))))
- (test-equal '((c . d)) (dict->alist dtd d)))
+ (test-equal '((c . d)) (dict->alist dto d)))
(when mutable?
(test-skip 1))
(test-group
- "dict-alter"
+ "dict-find-update"
;; ignore
(let ()
- (define dict (dict-alter dtd (alist->dict '((a . b))) 'c
+ (define dict (dict-find-update dto (alist->dict '((a . b))) 'c
(lambda (insert ignore)
(ignore))
(lambda args
(error "shouldn't happen"))))
- (test-equal '((a . b)) (dict->alist dtd dict)))
+ (test-equal '((a . b)) (dict->alist dto dict)))
;; insert
(let ()
(define dict-original (alist->dict '((a . b))))
- (define dict (dict-alter dtd dict-original 'c
+ (define dict (dict-find-update dto dict-original 'c
(lambda (insert ignore)
(insert 'd))
(lambda args
(error "shouldn't happen"))))
- (test-equal 'b (dict-ref dtd dict 'a))
- (test-equal 'd (dict-ref dtd dict 'c))
- (test-equal #f (dict-ref/default dtd dict-original 'c #f)))
+ (test-equal 'b (dict-ref dto dict 'a))
+ (test-equal 'd (dict-ref dto dict 'c))
+ (test-equal #f (dict-ref/default dto dict-original 'c #f)))
;; update
(let ()
(define dict-original (alist->dict '((a . b))))
- (define dict (dict-alter dtd dict-original 'a
+ (define dict (dict-find-update dto dict-original 'a
(lambda args
(error "shouldn't happen"))
(lambda (key value update delete)
(update 'a2 'b2))))
- (test-equal '((a2 . b2)) (dict->alist dtd dict))
- (test-equal #f (dict-ref/default dtd dict-original 'a2 #f))
- (test-equal 'b (dict-ref dtd dict-original 'a)))
+ (test-equal '((a2 . b2)) (dict->alist dto dict))
+ (test-equal #f (dict-ref/default dto dict-original 'a2 #f))
+ (test-equal 'b (dict-ref dto dict-original 'a)))
;; delete
(let ()
(define dict-original (alist->dict '((a . b) (c . d))))
- (define dict (dict-alter dtd dict-original 'a
+ (define dict (dict-find-update dto dict-original 'a
(lambda args
(error "shouldn't happen"))
(lambda (key value update delete)
(delete))))
- (test-equal '((c . d)) (dict->alist dtd dict))
- (test-equal 'b (dict-ref dtd dict-original 'a))))
+ (test-equal '((c . d)) (dict->alist dto dict))
+ (test-equal 'b (dict-ref dto dict-original 'a))))
(unless mutable?
(test-skip 1))
(test-group
- "dict-alter!"
+ "dict-find-update!"
;; ignore
(let ()
- (define dict (dict-alter! dtd (alist->dict '((a . b))) 'c
+ (define dict (dict-find-update! dto (alist->dict '((a . b))) 'c
(lambda (insert ignore)
(ignore))
(lambda args
(error "shouldn't happen"))))
- (test-equal '((a . b)) (dict->alist dtd dict)))
+ (test-equal '((a . b)) (dict->alist dto dict)))
;; insert
(let ()
- (define dict (dict-alter! dtd (alist->dict '((a . b))) 'c
+ (define dict (dict-find-update! dto (alist->dict '((a . b))) 'c
(lambda (insert ignore)
(insert 'd))
(lambda args
(error "shouldn't happen"))))
- (test-equal 'b (dict-ref dtd dict 'a))
- (test-equal 'd (dict-ref dtd dict 'c)))
+ (test-equal 'b (dict-ref dto dict 'a))
+ (test-equal 'd (dict-ref dto dict 'c)))
;; update
(let ()
- (define dict (dict-alter! dtd (alist->dict '((a . b))) 'a
+ (define dict (dict-find-update! dto (alist->dict '((a . b))) 'a
(lambda args
(error "shouldn't happen"))
(lambda (key value update delete)
(update 'a2 'b2))))
- (test-equal '((a2 . b2)) (dict->alist dtd dict)))
+ (test-equal '((a2 . b2)) (dict->alist dto dict)))
;; delete
(let ()
- (define dict (dict-alter! dtd (alist->dict '((a . b) (c . d))) 'a
+ (define dict (dict-find-update! dto (alist->dict '((a . b) (c . d))) 'a
(lambda args
(error "shouldn't happen"))
(lambda (key value update delete)
(delete))))
- (test-equal '((c . d)) (dict->alist dtd dict))))
+ (test-equal '((c . d)) (dict->alist dto dict))))
(test-group
"dict-size"
- (test-equal 2 (dict-size dtd (alist->dict '((a . b) (c . d)))))
- (test-equal 0 (dict-size dtd (alist->dict '()))))
+ (test-equal 2 (dict-size dto (alist->dict '((a . b) (c . d)))))
+ (test-equal 0 (dict-size dto (alist->dict '()))))
(test-group
"dict-count"
- (define count (dict-count dtd
+ (define count (dict-count dto
(lambda (key value)
(equal? value 'b))
(alist->dict '((a . b) (c . d)))))
@@ -566,7 +566,7 @@
(let ()
(define value
- (dict-any dtd
+ (dict-any dto
(lambda (key value)
(if (equal? 'b value) 'foo #f))
(alist->dict '((a . b) (c . d)))))
@@ -574,7 +574,7 @@
(let ()
(define value
- (dict-any dtd
+ (dict-any dto
(lambda (key value)
(if (equal? 'e value) 'foo #f))
(alist->dict '((a . b) (c . d)))))
@@ -584,7 +584,7 @@
"dict-every"
(let ()
(define value
- (dict-every dtd
+ (dict-every dto
(lambda (key value)
(if (equal? 'b value) 'foo #f))
(alist->dict '((a . b) (c . b)))))
@@ -592,7 +592,7 @@
(let ()
(define value
- (dict-every dtd
+ (dict-every dto
(lambda (key value)
(if (equal? 'b value) 'foo #f))
(alist->dict '())))
@@ -600,7 +600,7 @@
(let ()
(define value
- (dict-every dtd
+ (dict-every dto
(lambda (key value)
(if (equal? 'b value) 'foo #f))
(alist->dict '((a . b) (c . d)))))
@@ -609,7 +609,7 @@
(test-group
"dict-keys"
(define keys
- (dict-keys dtd (alist->dict '((a . b) (c . d)))))
+ (dict-keys dto (alist->dict '((a . b) (c . d)))))
(test-assert
(or (equal? '(a c) keys)
(equal? '(c a) keys))))
@@ -617,7 +617,7 @@
(test-group
"dict-values"
(define vals
- (dict-values dtd (alist->dict '((a . b) (c . d)))))
+ (dict-values dto (alist->dict '((a . b) (c . d)))))
(test-assert
(or (equal? '(b d) vals)
(equal? '(d b) vals))))
@@ -626,7 +626,7 @@
"dict-entries"
(define-values
(keys vals)
- (dict-entries dtd (alist->dict '((a . b) (c . d)))))
+ (dict-entries dto (alist->dict '((a . b) (c . d)))))
(test-assert
(or (and (equal? '(a c) keys)
(equal? '(b d) vals))
@@ -636,7 +636,7 @@
(test-group
"dict-fold"
(define value
- (dict-fold dtd
+ (dict-fold dto
(lambda (key value acc)
(append acc (list key value)))
'()
@@ -648,7 +648,7 @@
(test-group
"dict-map->list"
(define lst
- (dict-map->list dtd
+ (dict-map->list dto
(lambda (key value)
(string-append (symbol->string key)
value))
@@ -660,7 +660,7 @@
(test-group
"dict->alist"
(define alist
- (dict->alist dtd (alist->dict '((a . b) (c . d)))))
+ (dict->alist dto (alist->dict '((a . b) (c . d)))))
(test-assert
(or (equal? '((a . b) (c . d)) alist)
(equal? '((c . d) (a . b)) alist))))
@@ -668,8 +668,8 @@
(test-group
"dict-comparator"
;; extremelly basic generic test; more useful specific tests defined separately
- ;; for each dtd
- (let ((cmp (dict-comparator dtd (alist->dict '((a . b))))))
+ ;; for each dto
+ (let ((cmp (dict-comparator dto (alist->dict '((a . b))))))
(test-assert (or (not cmp)
(comparator? cmp)))))
@@ -677,7 +677,7 @@
"dict-for-each"
(test-for-each #t
(lambda (proc)
- (dict-for-each dtd
+ (dict-for-each dto
proc
(alist->dict '((1 . a)
(2 . b)
@@ -687,11 +687,11 @@
(test-group
"dict-for-each<"
- (test-for-each (let* ((cmp (dict-comparator dtd (alist->dict '())))
+ (test-for-each (let* ((cmp (dict-comparator dto (alist->dict '())))
(ordering (and cmp (comparator-ordered? cmp))))
ordering)
(lambda (proc)
- (dict-for-each< dtd
+ (dict-for-each< dto
proc
(alist->dict '((1 . a)
(2 . b)
@@ -702,11 +702,11 @@
(test-group
"dict-for-each<="
- (test-for-each (let* ((cmp (dict-comparator dtd (alist->dict '())))
+ (test-for-each (let* ((cmp (dict-comparator dto (alist->dict '())))
(ordering (and cmp (comparator-ordered? cmp))))
ordering)
(lambda (proc)
- (dict-for-each<= dtd
+ (dict-for-each<= dto
proc
(alist->dict '((1 . a)
(2 . b)
@@ -717,11 +717,11 @@
(test-group
"dict-for-each>"
- (test-for-each (let* ((cmp (dict-comparator dtd (alist->dict '())))
+ (test-for-each (let* ((cmp (dict-comparator dto (alist->dict '())))
(ordering (and cmp (comparator-ordered? cmp))))
ordering)
(lambda (proc)
- (dict-for-each> dtd
+ (dict-for-each> dto
proc
(alist->dict '((1 . a)
(2 . b)
@@ -732,11 +732,11 @@
(test-group
"dict-for-each>="
- (test-for-each (let* ((cmp (dict-comparator dtd (alist->dict '())))
+ (test-for-each (let* ((cmp (dict-comparator dto (alist->dict '())))
(ordering (and cmp (comparator-ordered? cmp))))
ordering)
(lambda (proc)
- (dict-for-each>= dtd
+ (dict-for-each>= dto
proc
(alist->dict '((1 . a)
(2 . b)
@@ -747,11 +747,11 @@
(test-group
"dict-for-each-in-open-interval"
- (test-for-each (let* ((cmp (dict-comparator dtd (alist->dict '())))
+ (test-for-each (let* ((cmp (dict-comparator dto (alist->dict '())))
(ordering (and cmp (comparator-ordered? cmp))))
ordering)
(lambda (proc)
- (dict-for-each-in-open-interval dtd
+ (dict-for-each-in-open-interval dto
proc
(alist->dict '((1 . a)
(2 . b)
@@ -762,11 +762,11 @@
(test-group
"dict-for-each-in-closed-interval"
- (test-for-each (let* ((cmp (dict-comparator dtd (alist->dict '())))
+ (test-for-each (let* ((cmp (dict-comparator dto (alist->dict '())))
(ordering (and cmp (comparator-ordered? cmp))))
ordering)
(lambda (proc)
- (dict-for-each-in-closed-interval dtd
+ (dict-for-each-in-closed-interval dto
proc
(alist->dict '((1 . a)
(2 . b)
@@ -777,11 +777,11 @@
(test-group
"dict-for-each-in-open-closed-interval"
- (test-for-each (let* ((cmp (dict-comparator dtd (alist->dict '())))
+ (test-for-each (let* ((cmp (dict-comparator dto (alist->dict '())))
(ordering (and cmp (comparator-ordered? cmp))))
ordering)
(lambda (proc)
- (dict-for-each-in-open-closed-interval dtd
+ (dict-for-each-in-open-closed-interval dto
proc
(alist->dict '((1 . a)
(2 . b)
@@ -792,11 +792,11 @@
(test-group
"dict-for-each-in-closed-open-interval"
- (test-for-each (let* ((cmp (dict-comparator dtd (alist->dict '())))
+ (test-for-each (let* ((cmp (dict-comparator dto (alist->dict '())))
(ordering (and cmp (comparator-ordered? cmp))))
ordering)
(lambda (proc)
- (dict-for-each-in-closed-open-interval dtd
+ (dict-for-each-in-closed-open-interval dto
proc
(alist->dict '((1 . a)
(2 . b)
@@ -812,26 +812,26 @@
(generator-for-each
(lambda (entry)
(proc (car entry) (cdr entry)))
- (make-dict-generator dtd (alist->dict '((1 . a)
+ (make-dict-generator dto (alist->dict '((1 . a)
(2 . b)
(3 . c))))))
'(1 2 3)))
(test-group
"dict-set-accumulator"
- (define acc (dict-set-accumulator dtd (alist->dict '())))
+ (define acc (dict-set-accumulator dto (alist->dict '())))
(acc (cons 1 'a))
(acc (cons 2 'b))
(acc (cons 2 'c))
- (test-assert (dict=? dtd equal? (acc (eof-object)) (alist->dict '((1 . a) (2 . c))))))
+ (test-assert (dict=? dto equal? (acc (eof-object)) (alist->dict '((1 . a) (2 . c))))))
(test-group
"dict-adjoin-accumulator"
- (define acc (dict-adjoin-accumulator dtd (alist->dict '())))
+ (define acc (dict-adjoin-accumulator dto (alist->dict '())))
(acc (cons 1 'a))
(acc (cons 2 'b))
(acc (cons 2 'c))
- (test-assert (dict=? dtd equal? (acc (eof-object)) (alist->dict '((1 . a) (2 . b))))))
+ (test-assert (dict=? dto equal? (acc (eof-object)) (alist->dict '((1 . a) (2 . b))))))
;; check all procs were called
(for-each
@@ -845,17 +845,17 @@
(test-group
"default"
;; test defaults by overring only procedures that raise error otherwise
- (define alist-dtd (make-alist-dtd equal?))
- (define minimal-alist-dtd
- (make-dtd
- dictionary?-id (dtd-ref alist-dtd dictionary?-id)
- dict-mutable?-id (dtd-ref alist-dtd dict-mutable?-id)
- dict-size-id (dtd-ref alist-dtd dict-size-id)
- dict-alter-id (dtd-ref alist-dtd dict-alter-id)
- dict-for-each-id (dtd-ref alist-dtd dict-for-each-id)
- dict-comparator-id (dtd-ref alist-dtd dict-comparator-id)))
+ (define alist-dto (make-alist-dto equal?))
+ (define minimal-alist-dto
+ (make-dto
+ dictionary?-id (dto-ref alist-dto dictionary?-id)
+ dict-mutable?-id (dto-ref alist-dto dict-mutable?-id)
+ dict-size-id (dto-ref alist-dto dict-size-id)
+ dict-find-update-id (dto-ref alist-dto dict-find-update-id)
+ dict-for-each-id (dto-ref alist-dto dict-for-each-id)
+ dict-comparator-id (dto-ref alist-dto dict-comparator-id)))
(do-test
- minimal-alist-dtd
+ minimal-alist-dto
alist-copy
#f
#f))
@@ -863,7 +863,7 @@
(test-group
"alist"
(do-test
- (make-alist-dtd equal?)
+ (make-alist-dto equal?)
;; copy to a mutable list instead of using identity function
;; so that mutating procedures don't fail
alist-copy
@@ -872,7 +872,7 @@
(test-group
"alist dict-comparator"
- (test-assert (not (dict-comparator alist-equal-dtd '())))))
+ (test-assert (not (dict-comparator alist-equal-dto '())))))
(cond-expand
((and (library (srfi 69))
@@ -881,7 +881,7 @@
(test-group
"srfi-69"
(do-test
- srfi-69-dtd
+ srfi-69-dto
(lambda (alist)
(define table (t69-make-hash-table equal?))
(for-each
@@ -898,7 +898,7 @@
(test-group
"srfi-125 mutable"
(do-test
- hash-table-dtd
+ hash-table-dto
(lambda (alist)
(define table (t125-hash-table-empty-copy (t125-make-hash-table equal?)))
(for-each
@@ -911,7 +911,7 @@
(test-group
"srfi-125 immutable"
(do-test
- hash-table-dtd
+ hash-table-dto
(lambda (alist)
(define table (t125-hash-table-empty-copy (t125-make-hash-table equal?)))
(for-each
@@ -928,7 +928,7 @@
(test-group
"srfi-126 (r6rs) mutable"
(do-test
- srfi-126-dtd
+ srfi-126-dto
(lambda (alist)
(define table (t126-make-eqv-hashtable))
(for-each
@@ -941,7 +941,7 @@
(test-group
"srfi-126 (r6rs) immutable"
(do-test
- srfi-126-dtd
+ srfi-126-dto
(lambda (alist)
(define table (t126-make-eqv-hashtable))
(for-each
@@ -960,7 +960,7 @@
"srfi-146"
(define cmp (make-default-comparator))
(do-test
- mapping-dtd
+ mapping-dto
(lambda (alist)
(let loop ((table (mapping cmp))
(entries alist))
@@ -972,13 +972,13 @@
#f)
(test-group
"srfi-146 dict-comparator"
- (test-equal cmp (dict-comparator mapping-dtd (mapping cmp)))))
+ (test-equal cmp (dict-comparator mapping-dto (mapping cmp)))))
(test-group
"srfi-146 hash"
(define cmp (make-default-comparator))
(do-test
- hash-mapping-dtd
+ hash-mapping-dto
(lambda (alist)
(let loop ((table (hashmap cmp))
(entries alist))
@@ -990,7 +990,7 @@
#f)
(test-group
"srfi-146 hash dict-comparator"
- (test-equal cmp (dict-comparator hash-mapping-dtd (hashmap cmp))))))
+ (test-equal cmp (dict-comparator hash-mapping-dto (hashmap cmp))))))
(else))
(test-end)