(import (scheme base) (only (csc sort) sort) (only (csc testing) assert-equal test) (csc hash-map)) (define (hash-symbol s) (hash-bytevector (string->utf8 (symbol->string s)))) (define (symbolstring s1) (symbol->string s2))) (define (alist->hash-map->alist l) (hash-map->alist (alist->hash-map hash-symbol symbolalist-singleton (assert-equal (sort-alist '((a . 1))) (sort-alist (alist->hash-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 hash-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)))))) (test hash-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)))))) (test hash-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 . ())))))) (test hash-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 . ())))))) (test hash-map->alist-overwrite (assert-equal (sort-alist '((a . 2))) (sort-alist (alist->hash-map->alist '((a . 1) (a . 2)))))) (test hash-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 . ()))))))