branch: elpa/parseclj
commit 2da47798d97fbd15cc8dcf9584d3a0511a74707f
Author: Arne Brasseur <[email protected]>
Commit: Arne Brasseur <[email protected]>
Enable more edn.el tests, document how time/uuid are stored
---
DESIGN.md | 5 ++-
tests/edn-el-test-suite.el | 79 +++++++++++++++++++++++-----------------------
2 files changed, 44 insertions(+), 40 deletions(-)
diff --git a/DESIGN.md b/DESIGN.md
index 064618274e..1bc710156f 100644
--- a/DESIGN.md
+++ b/DESIGN.md
@@ -29,6 +29,7 @@ The data structures available in Emacs are less rich than
those used by Clojure.
- Clojure has `nil` and `false`, Emacs only has `nil`.
- Emacs has no notion of sets
- Emacs has no date/timestamp type
+ - there is a `time-date.el` which has functions for working with day/time
represented as cons cells.
- Emacs has no "character" type (characters are represented as numbers)
- Emacs does not support custom records/types (there is a Common Lisp inspired
object system, but it implements types on top of regular lists and vectors).
- Emacs does not support adding metadata to values
@@ -237,7 +238,9 @@ See also the section at the top regarding differences
between Clojure's data typ
These are the choices that the edn.el library has made:
-- represent sets as `'(edn-set (... set values ...))`
+- represent sets, inst and uuid values as `cl-defstruct` objects
+ - `'(edn-set (... set values ...))`
+ - `'(edn-inst high low)` see `time-date.el`
- parse maps as hash tables
- represent characters as integers, *but* parse `\newline` `\return` `\space`
and `\tab` as the symbols `'newline` `'return` etc.
- parse `true` as `t`, `nil` and `false` as `nil`.
diff --git a/tests/edn-el-test-suite.el b/tests/edn-el-test-suite.el
index 7a2387b021..ba854a5b87 100644
--- a/tests/edn-el-test-suite.el
+++ b/tests/edn-el-test-suite.el
@@ -135,36 +135,36 @@
(puthash (pop keys-and-values) (pop keys-and-values) m))
m))
-;; (ert-deftest maps ()
-;; :tags '(edn maps)
-;; (should (hash-table-p (clj-parse-edn-str "{ }")))
-;; (should (hash-table-p (clj-parse-edn-str "{}")))
-;; (should (map-equal (make-seeded-hash-table :foo :bar :baz :qux)
-;; (clj-parse-edn-str "{ :foo :bar :baz :qux}")))
-;; (should (map-equal (make-seeded-hash-table 1 "123" 'vector [1 2 3])
-;; (clj-parse-edn-str "{ 1 \"123\" vector [1 2 3]}")))
-;; (should (map-equal (make-seeded-hash-table [1 2 3] "some numbers")
-;; (clj-parse-edn-str "{[1 2 3] \"some numbers\"}"))))
-
-;; (ert-deftest sets ()
-;; :tags '(edn sets)
-;; (should (edn-set-p (clj-parse-edn-str "#{}")))
-;; (should (edn-set-p (clj-parse-edn-str "#{ }")))
-;; (should (equal (edn-list-to-set '(1 2 3)) (clj-parse-edn-str "#{1 2 3}")))
-;; (should (equal (edn-list-to-set '(1 [1 2 3] 3)) (clj-parse-edn-str "#{1
[1 2 3] 3}"))))
-
-;; (ert-deftest comment ()
-;; :tags '(edn comments)
-;; (should-not (clj-parse-edn-str ";nada"))
-;; (should (equal 1 (clj-parse-edn-str ";; comment
-;; 1")))
-;; (should (equal [1 2 3] (clj-parse-edn-str "[1 2 ;comment to eol
-;; 3]")))
-;; (should (equal '[valid more items] (clj-parse-edn-str "[valid;touching
trailing comment
-;; more items]")))
-;; (should (equal [valid vector more vector items] (clj-parse-edn-str
"[valid vector
-;; ;;comment in vector
-;; more vector items]"))))
+(ert-deftest maps ()
+ :tags '(edn maps)
+ (should (hash-table-p (clj-parse-edn-str "{ }")))
+ (should (hash-table-p (clj-parse-edn-str "{}")))
+ (should (map-equal (make-seeded-hash-table :foo :bar :baz :qux)
+ (clj-parse-edn-str "{ :foo :bar :baz :qux}")))
+ (should (map-equal (make-seeded-hash-table 1 "123" 'vector [1 2 3])
+ (clj-parse-edn-str "{ 1 \"123\" vector [1 2 3]}")))
+ (should (map-equal (make-seeded-hash-table [1 2 3] "some numbers")
+ (clj-parse-edn-str "{[1 2 3] \"some numbers\"}"))))
+
+(ert-deftest sets ()
+ :tags '(edn sets)
+ (should (edn-set-p (clj-parse-edn-str "#{}")))
+ (should (edn-set-p (clj-parse-edn-str "#{ }")))
+ (should (equal (edn-list-to-set '(1 2 3)) (clj-parse-edn-str "#{1 2 3}")))
+ (should (equal (edn-list-to-set '(1 [1 2 3] 3)) (clj-parse-edn-str "#{1 [1 2
3] 3}"))))
+
+(ert-deftest comment ()
+ :tags '(edn comments)
+ (should-not (clj-parse-edn-str ";nada"))
+ (should (equal 1 (clj-parse-edn-str ";; comment
+1")))
+ (should (equal [1 2 3] (clj-parse-edn-str "[1 2 ;comment to eol
+3]")))
+ (should (equal '[valid more items] (clj-parse-edn-str "[valid;touching
trailing comment
+ more items]")))
+ (should (equal [valid vector more vector items] (clj-parse-edn-str "[valid
vector
+ ;;comment in vector
+ more vector items]"))))
;; (defun test-val-passed-to-handler (val)
;; (should (listp val))
@@ -181,15 +181,16 @@
;; (should (= 1 (clj-parse-edn-str "#my/type (1 2)")))
;; (should (= 2 (clj-parse-edn-str "#my/other-type {:foo :bar}"))))
-;; (ert-deftest roundtrip ()
-;; :tags '(edn roundtrip)
-;; (let ((data [1 2 3 :foo (4 5) qux "quux"]))
-;; (should (equal data (clj-parse-edn-str (edn-print-string data))))
-;; (should (map-equal (make-seeded-hash-table :foo :bar)
-;; (clj-parse-edn-str (edn-print-string
(make-seeded-hash-table :foo :bar)))))
-;; (should (equal (edn-list-to-set '(1 2 3 [3 1.11]))
-;; (clj-parse-edn-str (edn-print-string (edn-list-to-set
'(1 2 3 [3 1.11]))))))
-;; (should-error (clj-parse-edn-str "#myapp/Person {:first \"Fred\" :last
\"Mertz\"}"))))
+(ert-deftest roundtrip ()
+ :tags '(edn roundtrip)
+ (let ((data [1 2 3 :foo (4 5) qux "quux"]))
+ (should (equal data (clj-parse-edn-str (edn-print-string data))))
+ (should (map-equal (make-seeded-hash-table :foo :bar)
+ (clj-parse-edn-str (edn-print-string
(make-seeded-hash-table :foo :bar)))))
+ (should (equal (edn-list-to-set '(1 2 3 [3 1.11]))
+ (clj-parse-edn-str (edn-print-string (edn-list-to-set '(1 2
3 [3 1.11]))))))
+ ;;(should-error (clj-parse-edn-str "#myapp/Person {:first \"Fred\" :last
\"Mertz\"}"))
+ ))
;; (ert-deftest inst ()
;; :tags '(edn inst)