diff options
| author | 2021-06-24 19:24:32 -0400 | |
|---|---|---|
| committer | 2021-06-24 19:24:32 -0400 | |
| commit | 570845a2289b1feffd89928e8472000cd79b723a (patch) | |
| tree | 213302b088d6686adedf17d3d2d4e80280a89bc0 /dictionaries-test.scm | |
| parent | added spec (diff) | |
| parent | Update spec.md (diff) | |
Merge remote-tracking branch 'origin/master'
Diffstat (limited to '')
| -rw-r--r-- | dictionaries-test.scm | 118 |
1 files changed, 88 insertions, 30 deletions
diff --git a/dictionaries-test.scm b/dictionaries-test.scm index ede4fe7..099229b 100644 --- a/dictionaries-test.scm +++ b/dictionaries-test.scm @@ -1,32 +1,48 @@ (import (scheme base) - (srfi 1) - (dictionaries)) + (scheme case-lambda) + (srfi 1)) (cond-expand - ((or srfi-64 kawa) - (import (srfi 64))) + (kawa (import (srfi 69 basic-hash-tables))) + ((library (srfi 125)) + (import (srfi 125))) + ((library (srfi 69)) + (import (srfi 69))) + (else)) + +(cond-expand + ((library (srfi 126)) + (import (srfi 126))) + (else)) + +(cond-expand + ((library (srfi 64)) + (import (srfi 64))) (chibi - (begin - (import (except (chibi test) test-equal)) - (define-syntax test-equal - (syntax-rules () - ((_ args ...) (test args ...)))) - )) + (import (except (chibi test) test-equal))) (else (error "No testing framework"))) (cond-expand - ((or srfi-125 chibi) - (import (srfi 125))) - (kawa - (import (srfi 69 basic-hash-tables))) - (srfi-69 - (import (srfi 69))) + (chibi + (define-syntax test-equal + (syntax-rules () + ((_ args ...) (test args ...))))) (else)) +; use include instead of import +; so that registering is done in isolated way +(include "indexes.scm") +(include "internals.scm") +(include "externals.scm") + +(define (clear-registry!) + (set! registry '())) + (define (do-test alist->dict) (test-group "dictionary?" + (test-assert (not (dictionary? 'foo))) (test-assert (dictionary? (alist->dict '()))) (test-assert (dictionary? (alist->dict '((a . b)))))) @@ -75,7 +91,7 @@ (test-group "dict-replace!" - (define d (dict-replace! '((a . b) (c . d)) 'a 'b2)) + (define d (dict-replace! (alist->dict '((a . b) (c . d))) 'a 'b2)) (test-equal 'b2 (dict-ref d 'a)) (test-equal 'd (dict-ref d 'c))) @@ -185,7 +201,7 @@ (let () (define-values (dict value) - (dict-search! '((a . b)) 'c + (dict-search! (alist->dict '((a . b))) 'c (lambda (insert ignore) (ignore 'foo)) (lambda args @@ -362,10 +378,20 @@ (test-group "alist" + (include "alist-impl.scm") + (clear-registry!) + (register-alist!) (do-test (lambda (alist) alist))) (test-group "plist" + ; empty list isn't valid plist dictionary, thus alist impl also has to be + ; added just for this edge case + (include "alist-impl.scm") + (include "plist-impl.scm") + (clear-registry!) + (register-plist!) + (register-alist!) (do-test (lambda (alist) (apply append @@ -374,17 +400,49 @@ alist))))) (cond-expand - ((or srfi-69 srfi-125 chibi kawa) - (begin - (test-group - "srfi-69" - (do-test (lambda (alist) - (define table (make-hash-table equal?)) - (for-each - (lambda (pair) - (hash-table-set! table (car pair) (cdr pair))) - alist) - table))))) - (else)) + ((or (library (srfi 69)) + (library (srfi 125))) + (test-group + "srfi-69" + (include "srfi-69-impl.scm") + (clear-registry!) + (register-srfi-69!) + (do-test (lambda (alist) + (define table (make-hash-table equal?)) + (for-each + (lambda (pair) + (hash-table-set! table (car pair) (cdr pair))) + alist) + table))))) + +(cond-expand + ((library (srfi 125)) + (test-group + "srfi-125" + (include "srfi-125-impl.scm") + (clear-registry!) + (register-srfi-125!) + (do-test (lambda (alist) + (define table (make-hash-table equal?)) + (for-each + (lambda (pair) + (hash-table-set! table (car pair) (cdr pair))) + alist) + table))))) + +(cond-expand + ((library (srfi 126)) + (test-group + "srfi-126 (r6rs)" + (include "srfi-126-impl.scm") + (clear-registry!) + (register-srfi-126!) + (do-test (lambda (alist) + (define table (make-eqv-hashtable)) + (for-each + (lambda (pair) + (hashtable-set! table (car pair) (cdr pair))) + alist) + table))))) (test-end) |
