diff options
| author | 2022-02-15 14:13:27 +0200 | |
|---|---|---|
| committer | 2022-02-15 14:13:27 +0200 | |
| commit | fd3fcee4477de39c74ec4c88964d671bf43fd071 (patch) | |
| tree | c71eaea1223060db846dcd40e34ae29c5a4153e5 /srfi-225-test.scm | |
| parent | Merge branch 'master' of https://github.com/johnwcowan/srfi-225 (diff) | |
update implementation
Diffstat (limited to 'srfi-225-test.scm')
| -rw-r--r-- | srfi-225-test.scm | 203 |
1 files changed, 83 insertions, 120 deletions
diff --git a/srfi-225-test.scm b/srfi-225-test.scm index d4d601b..c36b062 100644 --- a/srfi-225-test.scm +++ b/srfi-225-test.scm @@ -75,6 +75,9 @@ (call/cc (lambda (cont) (with-exception-handler (lambda (err) + (when expect-success + (display err) + (newline)) (unless expect-success (cont #t))) (lambda () @@ -717,140 +720,78 @@ (2 . b) (3 . c) (4 . d))))) - '(1 2 3 4))) - - (test-group - "dict-for-each<" - (test-for-each (let* ((cmp (dict-comparator dto (alist->dict '()))) - (ordering (and cmp (comparator-ordered? cmp)))) - ordering) - (lambda (proc) - (dict-for-each< dto - proc - (alist->dict '((1 . a) - (2 . b) - (3 . c) - (4 . d))) - 3)) - '(1 2))) - - (test-group - "dict-for-each<=" - (test-for-each (let* ((cmp (dict-comparator dto (alist->dict '()))) - (ordering (and cmp (comparator-ordered? cmp)))) - ordering) - (lambda (proc) - (dict-for-each<= dto - proc - (alist->dict '((1 . a) - (2 . b) - (3 . c) - (4 . d))) - 3)) - '(1 2 3))) - - (test-group - "dict-for-each>" + '(1 2 3 4)) + (test-for-each (let* ((cmp (dict-comparator dto (alist->dict '()))) (ordering (and cmp (comparator-ordered? cmp)))) ordering) - (lambda (proc) - (dict-for-each> dto - proc - (alist->dict '((1 . a) - (2 . b) - (3 . c) - (4 . d))) - 2)) - '(3 4))) - - (test-group - "dict-for-each>=" - (test-for-each (let* ((cmp (dict-comparator dto (alist->dict '()))) - (ordering (and cmp (comparator-ordered? cmp)))) - ordering) - (lambda (proc) - (dict-for-each>= dto - proc - (alist->dict '((1 . a) - (2 . b) - (3 . c) - (4 . d))) - 2)) - '(2 3 4))) + (lambda (proc) + (dict-for-each dto + proc + (alist->dict '((1 . a) + (2 . b) + (3 . c) + (4 . d))) + 2)) + '(2 3 4)) - (test-group - "dict-for-each-in-open-interval" - (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 dto - proc - (alist->dict '((1 . a) - (2 . b) - (3 . c) - (4 . d))) - 1 4)) - '(2 3))) - - (test-group - "dict-for-each-in-closed-interval" (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 dto - proc - (alist->dict '((1 . a) - (2 . b) - (3 . c) - (4 . d))) - 1 4)) - '(1 2 3 4))) + (lambda (proc) + (dict-for-each dto + proc + (alist->dict '((1 . a) + (2 . b) + (3 . c) + (4 . d))) + 2 + 3)) + '(2 3))) + + (test-group + "dict->generator" + (test-for-each #t + (lambda (proc) + (generator-for-each + (lambda (entry) + (proc (car entry) (cdr entry))) + (dict->generator dto (alist->dict '((1 . a) + (2 . b) + (3 . c) + (4 . d)))))) + '(1 2 3 4)) - (test-group - "dict-for-each-in-open-closed-interval" (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 dto - proc - (alist->dict '((1 . a) - (2 . b) - (3 . c) - (4 . d))) - 1 4)) - '(2 3 4))) + (lambda (proc) + (generator-for-each + (lambda (entry) + (proc (car entry) (cdr entry))) + (dict->generator dto (alist->dict '((1 . a) + (2 . b) + (3 . c) + (4 . d))) + 2))) + '(2 3 4)) - (test-group - "dict-for-each-in-closed-open-interval" (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 dto - proc - (alist->dict '((1 . a) - (2 . b) - (3 . c) - (4 . d))) - 1 4)) - '(1 2 3))) - - (test-group - "make-dict-generator" - (test-for-each #t - (lambda (proc) - (generator-for-each - (lambda (entry) - (proc (car entry) (cdr entry))) - (make-dict-generator dto (alist->dict '((1 . a) - (2 . b) - (3 . c)))))) - '(1 2 3))) + (lambda (proc) + (generator-for-each + (lambda (entry) + (proc (car entry) (cdr entry))) + (dict->generator dto (alist->dict '((1 . a) + (2 . b) + (3 . c) + (4 . d))) + 2 3))) + '(2 3))) + (when mutable? + (test-skip 1)) (test-group "dict-set-accumulator" (define acc (dict-set-accumulator dto (alist->dict '()))) @@ -858,7 +799,19 @@ (acc (cons 2 'b)) (acc (cons 2 'c)) (test-assert (dict=? dto equal? (acc (eof-object)) (alist->dict '((1 . a) (2 . c)))))) + + (unless mutable? + (test-skip 1)) + (test-group + "dict-set!-accumulator" + (define acc (dict-set!-accumulator dto (alist->dict '()))) + (acc (cons 1 'a)) + (acc (cons 2 'b)) + (acc (cons 2 'c)) + (test-assert (dict=? dto equal? (acc (eof-object)) (alist->dict '((1 . a) (2 . c)))))) + (when mutable? + (test-skip 1)) (test-group "dict-adjoin-accumulator" (define acc (dict-adjoin-accumulator dto (alist->dict '()))) @@ -866,6 +819,16 @@ (acc (cons 2 'b)) (acc (cons 2 'c)) (test-assert (dict=? dto equal? (acc (eof-object)) (alist->dict '((1 . a) (2 . b)))))) + + (unless mutable? + (test-skip 1)) + (test-group + "dict-adjoin!-accumulator" + (define acc (dict-adjoin!-accumulator dto (alist->dict '()))) + (acc (cons 1 'a)) + (acc (cons 2 'b)) + (acc (cons 2 'c)) + (test-assert (dict=? dto equal? (acc (eof-object)) (alist->dict '((1 . a) (2 . b)))))) ;; check all procs were called (for-each @@ -883,10 +846,10 @@ (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-pure?-id (dto-ref alist-dto dict-pure?-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-map-id (dto-ref alist-dto dict-map-id) dict-comparator-id (dto-ref alist-dto dict-comparator-id))) (do-test minimal-alist-dto |
