aboutsummaryrefslogtreecommitdiffstats
path: root/csc/hash-map-test.csc
diff options
context:
space:
mode:
authorRose Hogenson <rhogenson@posteo.net>2022-07-24 16:20:00 -0700
committerRose Hogenson <rhogenson@posteo.net>2022-07-24 16:20:00 -0700
commitc04e3c7cd6726a95da3d58979f582afb7a5b722f (patch)
tree524f25bb188f90d68626a1f402f8de54e00848d4 /csc/hash-map-test.csc
parentImprove the loop macro collect statement. (diff)
downloadchromatopelma-c04e3c7cd6726a95da3d58979f582afb7a5b722f.tar.zst
Export some common comparers from hash-map.
Diffstat (limited to 'csc/hash-map-test.csc')
-rw-r--r--csc/hash-map-test.csc21
1 files changed, 5 insertions, 16 deletions
diff --git a/csc/hash-map-test.csc b/csc/hash-map-test.csc
index 7885908..da58e69 100644
--- a/csc/hash-map-test.csc
+++ b/csc/hash-map-test.csc
@@ -12,19 +12,8 @@
(csc hash-map))
-(define (hash-symbol s)
- (hash-bytevector (string->utf8 (symbol->string s))))
-
-
-(define (cmp-symbols s1 s2)
- (cond
- ((symbol=? s1 s2) 0)
- ((string<? (symbol->string s1) (symbol->string s2)) -1)
- (else 1)))
-
-
(define (alist->map->alist l)
- (map->alist (alist->map hash-symbol cmp-symbols l)))
+ (map->alist (alist->map compare-symbols l)))
(test map->alist-singleton
@@ -78,18 +67,18 @@
(test lookup
(assert-equal
2
- (lookup (alist->map hash-symbol cmp-symbols '((a . 1) (b . 2) (c . 3))) 'b)))
+ (lookup (alist->map compare-symbols '((a . 1) (b . 2) (c . 3))) 'b)))
(test lookup-notfound
(assert-raises key-not-found-error?
- (lookup (alist->map hash-symbol cmp-symbols '((a . 1) (b . 2) (c . 3))) 'd)))
+ (lookup (alist->map compare-symbols '((a . 1) (b . 2) (c . 3))) 'd)))
(test lookup-default
(assert-equal
#f
- (lookup (alist->map hash-symbol cmp-symbols '((a . #t) (b . #t))) 'c #f)))
+ (lookup (alist->map compare-symbols '((a . #t) (b . #t))) 'c #f)))
(define transform-map
@@ -98,7 +87,7 @@
(define (test-map . bindings)
- (alist->map hash-symbol cmp-symbols bindings))
+ (alist->map compare-symbols bindings))
(test merge