aboutsummaryrefslogtreecommitdiffstats
path: root/hash-map-test.csc
diff options
context:
space:
mode:
Diffstat (limited to 'hash-map-test.csc')
-rw-r--r--hash-map-test.csc48
1 files changed, 30 insertions, 18 deletions
diff --git a/hash-map-test.csc b/hash-map-test.csc
index b1b98bd..353e6b4 100644
--- a/hash-map-test.csc
+++ b/hash-map-test.csc
@@ -2,6 +2,7 @@
(only (csc sort) sort)
(only (csc testing)
assert-equal
+ assert-raises
test)
(csc hash-map))
@@ -14,53 +15,64 @@
(string<? (symbol->string s1) (symbol->string s2)))
-(define (alist->hash-map->alist l)
- (hash-map->alist (alist->hash-map hash-symbol symbol<? l)))
+(define (alist->map->alist l)
+ (map->alist (alist->map hash-symbol symbol<? l)))
(define (sort-alist l)
(sort (lambda (x1 x2) (symbol<? (car x1) (car x2))) l))
-(test hash-map->alist-singleton
- (assert-equal (sort-alist '((a . 1))) (sort-alist (alist->hash-map->alist '((a . 1))))))
+(test map->alist-singleton
+ (assert-equal (sort-alist '((a . 1))) (sort-alist (alist->map->alist '((a . 1))))))
-(test hash-map->alist-two
- (assert-equal (sort-alist '((a . 1) (b . 2))) (sort-alist (alist->hash-map->alist '((a . 1) (b . 2))))))
+(test map->alist-two
+ (assert-equal (sort-alist '((a . 1) (b . 2))) (sort-alist (alist->map->alist '((a . 1) (b . 2))))))
-(test hash-map->alist-longer
+(test map->alist-longer
(assert-equal
(sort-alist '((a . 1) (b . 2) (c . 3) (d . 4) (e . 5) (f . 6)))
- (sort-alist (alist->hash-map->alist '((a . 1) (b . 2) (c . 3) (d . 4) (e . 5) (f . 6))))))
+ (sort-alist (alist->map->alist '((a . 1) (b . 2) (c . 3) (d . 4) (e . 5) (f . 6))))))
-(test hash-map->alist-larger
+(test map->alist-larger
(assert-equal
(sort-alist '((f . 5) (m . 1) (n . 7) (q . 3) (x . 8)))
- (sort-alist (alist->hash-map->alist '((m . 1) (n . 2) (q . 3) (f . 5) (n . 7) (x . 8))))))
+ (sort-alist (alist->map->alist '((m . 1) (n . 2) (q . 3) (f . 5) (n . 7) (x . 8))))))
-(test hash-map->alist-in-order
+(test map->alist-in-order
(assert-equal
(sort-alist '((a . ()) (b . ()) (c . ()) (d . ()) (e . ()) (f . ()) (g . ()) (h . ())))
- (sort-alist (alist->hash-map->alist '((a . ()) (b . ()) (c . ()) (d . ()) (e . ()) (f . ()) (g . ()) (h . ()))))))
+ (sort-alist (alist->map->alist '((a . ()) (b . ()) (c . ()) (d . ()) (e . ()) (f . ()) (g . ()) (h . ()))))))
-(test hash-map->alist-reversed
+(test map->alist-reversed
(assert-equal
(sort-alist '((h . ()) (g . ()) (f . ()) (e . ()) (d . ()) (c . ()) (b . ()) (a . ())))
- (sort-alist (alist->hash-map->alist '((a . ()) (b . ()) (c . ()) (d . ()) (e . ()) (f . ()) (g . ()) (h . ()))))))
+ (sort-alist (alist->map->alist '((a . ()) (b . ()) (c . ()) (d . ()) (e . ()) (f . ()) (g . ()) (h . ()))))))
-(test hash-map->alist-overwrite
+(test map->alist-overwrite
(assert-equal
(sort-alist '((a . 2)))
- (sort-alist (alist->hash-map->alist '((a . 1) (a . 2))))))
+ (sort-alist (alist->map->alist '((a . 1) (a . 2))))))
-(test hash-map->alist-alternating
+(test map->alist-alternating
(assert-equal
(sort-alist '((h . ()) (g . ()) (i . ()) (f . ()) (j . ()) (e . ()) (k . ()) (d . ()) (l . ()) (c . ())))
- (sort-alist (alist->hash-map->alist '((c . ()) (d . ()) (e . ()) (f . ()) (g . ()) (h . ()) (i . ()) (j . ()) (k . ()) (l . ()))))))
+ (sort-alist (alist->map->alist '((c . ()) (d . ()) (e . ()) (f . ()) (g . ()) (h . ()) (i . ()) (j . ()) (k . ()) (l . ()))))))
+
+
+(test lookup
+ (assert-equal
+ 2
+ (lookup (alist->map hash-symbol symbol<? '((a . 1) (b . 2) (c . 3))) 'b)))
+
+
+(test lookup-notfound
+ (assert-raises key-not-found-error?
+ (lookup (alist->map hash-symbol symbol<? '((a . 1) (b . 2) (c . 3))) 'd)))