From 77583a881b03ce38c8065c40641489fe88b61eb2 Mon Sep 17 00:00:00 2001 From: Rose Hogenson Date: Sun, 9 Jan 2022 22:55:59 -0800 Subject: Write the linker. --- hash-map-test.csc | 48 ++++++++++++++++++++++++++++++------------------ 1 file changed, 30 insertions(+), 18 deletions(-) (limited to 'hash-map-test.csc') 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 @@ (stringstring s1) (symbol->string s2))) -(define (alist->hash-map->alist l) - (hash-map->alist (alist->hash-map hash-symbol symbolmap->alist l) + (map->alist (alist->map hash-symbol symbolalist-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 symbolmap hash-symbol symbol