summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--mew.scm8
-rw-r--r--tests/test.mew5
2 files changed, 12 insertions, 1 deletions
diff --git a/mew.scm b/mew.scm
index 917ce6c..a6ac371 100644
--- a/mew.scm
+++ b/mew.scm
@@ -1181,6 +1181,14 @@
                      (str (substring old-prompt 0 2)
                           "^_^;"
                           (substring old-prompt 2))))))
+  (set-record-printer! 'hash-table
+    (lambda (h out)
+      (format out "#<hash-table")
+      (if (< 0 (hash-table-size h) 100)
+        (hash-table-for-each h (lambda (k v)
+                                 (format out " (~s . ~s)" k v)))
+        (format out " (~a)" (hash-table-size h)))
+      (format out ">")))
 
   (set-pseudo-random-seed! (random-bytes))
 )
diff --git a/tests/test.mew b/tests/test.mew
index 589b63e..1fe7ec1 100644
--- a/tests/test.mew
+++ b/tests/test.mew
@@ -329,7 +329,10 @@
   (test-assert (hash-table? (tbl 1 2 3 4)))
   (test 0 (hash-table-size (tbl)))
   (test 42 (get (tbl 1 2 3 42) 3))
-  (test-error (tbl 1 2 3)))
+  (test-error (tbl 1 2 3))
+
+  (test "#<hash-table (0)>" (format "~a" (tbl)))
+  (test "#<hash-table (42 . \"foo\")>" (format "~a" (tbl 42 "foo"))))
 
 (test-group "set-at"
   (test #(0 42 0) (set-at #(0 0 0) 1 42))