emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[nongnu] elpa/parseedn f42ff98833 13/32: Merge pull request #1 from ak-c


From: ELPA Syncer
Subject: [nongnu] elpa/parseedn f42ff98833 13/32: Merge pull request #1 from ak-coram/fix-hash-map-printing
Date: Tue, 28 Dec 2021 14:04:42 -0500 (EST)

branch: elpa/parseedn
commit f42ff988338484815ccd925c8f83a32c5d52319b
Merge: 342359abd1 0ffab01927
Author: Arne Brasseur <arne.brasseur@gmail.com>
Commit: GitHub <noreply@github.com>

    Merge pull request #1 from ak-coram/fix-hash-map-printing
    
    Fix hash map printing
---
 parseedn.el           |  6 +++---
 test/parseedn-test.el | 14 +++++++++++++-
 2 files changed, 16 insertions(+), 4 deletions(-)

diff --git a/parseedn.el b/parseedn.el
index 7b09f598c6..e969d23d42 100644
--- a/parseedn.el
+++ b/parseedn.el
@@ -141,16 +141,16 @@ TAG-READERS is an optional association list.  For more 
information, see
       (insert " ")
       (parseedn-print-seq next))))
 
-(defun parseedn-print-kvs (map)
+(defun parseedn-print-kvs (map &optional ks)
   "Insert hash table MAP as an EDN map into the current buffer."
-  (let ((keys (a-keys map)))
+  (let ((keys (or ks (a-keys map))))
     (parseedn-print (car keys))
     (insert " ")
     (parseedn-print (a-get map (car keys)))
     (let ((next (cdr keys)))
       (when (not (seq-empty-p next))
         (insert ", ")
-        (parseedn-print-kvs next)))))
+        (parseedn-print-kvs map next)))))
 
 (defun parseedn-print (datum)
   "Insert DATUM as EDN into the current buffer.
diff --git a/test/parseedn-test.el b/test/parseedn-test.el
index d9c3ce79d3..9ddbdb4409 100644
--- a/test/parseedn-test.el
+++ b/test/parseedn-test.el
@@ -37,7 +37,19 @@
   (should (equal (parseedn-print-str 100) "100"))
   (should (equal (parseedn-print-str 1.2) "1.2"))
   (should (equal (parseedn-print-str [1 2 3]) "[1 2 3]"))
-  (should (equal (parseedn-print-str t) "true")))
+  (should (equal (parseedn-print-str t) "true"))
+  (should (listp (member (parseedn-print-str
+                          (let ((ht (make-hash-table)))
+                            (puthash :a 1 ht)
+                            (puthash :b 2 ht)
+                            (puthash :c 3 ht)
+                            ht))
+                         '("{:a 1, :b 2, :c 3}"
+                           "{:a 1, :c 3, :b 2}"
+                           "{:b 2, :a 1, :c 3}"
+                           "{:b 2, :c 3, :a 1}"
+                           "{:c 3, :a 1, :b 2}"
+                           "{:c 3, :b 2, :a 1}")))))
 
 (ert-deftest parseedn-read-test ()
   (should (equal (parseedn-read-str "true") t)))



reply via email to

[Prev in Thread] Current Thread [Next in Thread]