[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/tomelr b64eb07e99 49/84: fix: Detect TT with sub-tables
From: |
ELPA Syncer |
Subject: |
[elpa] externals/tomelr b64eb07e99 49/84: fix: Detect TT with sub-tables correctly |
Date: |
Tue, 3 May 2022 09:58:12 -0400 (EDT) |
branch: externals/tomelr
commit b64eb07e99e9ab45cc88dc6b628f8bc828a0dc28
Author: Kaushal Modi <kaushal.modi@gmail.com>
Commit: Kaushal Modi <kaushal.modi@gmail.com>
fix: Detect TT with sub-tables correctly
---
test/tinternal.el | 8 ++++++--
test/ttable-array.el | 16 ++++++++++++++++
tomelr.el | 14 ++++++++------
3 files changed, 30 insertions(+), 8 deletions(-)
diff --git a/test/tinternal.el b/test/tinternal.el
index 0e46b57ebb..29346b43bf 100644
--- a/test/tinternal.el
+++ b/test/tinternal.el
@@ -31,6 +31,10 @@
(:a 1)
((a . 1) (b . 2))
(:a 1 :b 2)
+ ;; Nested TT
+ ((a . 1)
+ (b . ((c . 3)
+ (d . 4))))
)))
(dolist (el inp)
(should (equal t (tomelr--toml-table-p el))))))
@@ -47,10 +51,10 @@
;;;; tomelr--toml-table-array-p
(ert-deftest test-internal-valid-tta ()
(let ((inp '(
- ;; ;; TTA with 1 table of 1 key-val pair
+ ;; TTA with 1 table of 1 key-val pair
(((a . 1)))
((:a 1))
- ;; ;; TTA with 2 tables of 2 key-val pairs
+ ;; TTA with 2 tables of 2 key-val pairs
(((a . 1) (b . 2))
((a . 100) (b . 200)))
((:a 1 :b 2)
diff --git a/test/ttable-array.el b/test/ttable-array.el
index 5d1b2c4333..740cf10de9 100644
--- a/test/ttable-array.el
+++ b/test/ttable-array.el
@@ -62,6 +62,22 @@ See
[org#Drawers](https://www.gnu.org/software/emacs/manual/html_mono/org.html#D
(push (tomelr-encode el) out))
(should (equal ref (nreverse out)))))
+;;;; Sub-table in a TOML Table Array
+(ert-deftest test-subtable-in-tta ()
+ (let ((inp '(
+ ((fruits . (((name . "apple")
+ (physical . ((color . "red")
+ (shape . "round")))))))))
+ (ref '("[[fruits]]
+ name = \"apple\"
+ [fruits.physical]
+ color = \"red\"
+ shape = \"round\""))
+ out)
+ (dolist (el inp)
+ (push (tomelr-encode el) out))
+ (should (equal ref (nreverse out)))))
+
;;;; Nested array of tables
(ert-deftest test-nested-array-of-tables ()
(let ((inp '(
diff --git a/tomelr.el b/tomelr.el
index fc5bdc72a9..01b652b0f4 100644
--- a/tomelr.el
+++ b/tomelr.el
@@ -292,16 +292,18 @@ Definition of a TOML Table (TT):
;; (when (listp elem)
;; (message " [tomelr--toml-table-p DBG] sub-elem 0 = %S,
type = %S, len = %d"
;; (car elem) (type-of (car elem)) (safe-length
(car elem))))
- (and (consp elem)
- (= 1 (safe-length elem))
- (not (consp (car elem)))))
+ (or (and (consp elem)
+ (= 1 (safe-length elem))
+ (not (consp (car elem))))
+ (and (listp elem)
+ (symbolp (car elem))
+ (tomelr--toml-table-p (cdr elem)))))
object)
t)
- ((and (listp (car object))
- (symbolp (car (car object))))
- (tomelr--toml-table-p (cdr (car object))))
(t
nil))))
+ ;; (message "[tomelr--toml-table-p DBG] tablep = %S" tablep)
+ ;; (message "=====")
tablep))
(defun tomelr--print-pair (key val)
- [elpa] externals/tomelr 96c890a68b 23/84: feat: Convert Lisp lists to TOML arrays, (continued)
- [elpa] externals/tomelr 96c890a68b 23/84: feat: Convert Lisp lists to TOML arrays, ELPA Syncer, 2022/05/03
- [elpa] externals/tomelr bb85106ee9 27/84: doc: Add spec for nested tables and arrays of tables, ELPA Syncer, 2022/05/03
- [elpa] externals/tomelr 1d65064ffa 20/84: feat: Recognize local date format YYYY-MM-DD, ELPA Syncer, 2022/05/03
- [elpa] externals/tomelr 2810504e84 32/84: feat: Add basic support for S-exp plists -> TOML conversion, ELPA Syncer, 2022/05/03
- [elpa] externals/tomelr 0f4e7b4f2c 47/84: fix: Better detection of nested TTA, but still wip, ELPA Syncer, 2022/05/03
- [elpa] externals/tomelr cff1f8aa89 38/84: fix: Support TOML tables arrays specified as plist vector, ELPA Syncer, 2022/05/03
- [elpa] externals/tomelr 4c419bcee2 37/84: fix: Support TOML tables specified as plists, ELPA Syncer, 2022/05/03
- [elpa] externals/tomelr baf81228bc 45/84: fix: Correct the spec for nested array of tables, ELPA Syncer, 2022/05/03
- [elpa] externals/tomelr 4dda8e6be3 46/84: chore: Style edits in a test, ELPA Syncer, 2022/05/03
- [elpa] externals/tomelr 5959b90ffa 44/84: fix: Don't let TOML tables be recognized as TOML tables arrays, ELPA Syncer, 2022/05/03
- [elpa] externals/tomelr b64eb07e99 49/84: fix: Detect TT with sub-tables correctly,
ELPA Syncer <=
- [elpa] externals/tomelr 4386d99a85 65/84: refactor(minor): Use `tomelr--toml-table-p`, ELPA Syncer, 2022/05/03
- [elpa] externals/tomelr 26f1fc2f3c 55/84: doc: Update the medley example, ELPA Syncer, 2022/05/03
- [elpa] externals/tomelr e2b313ca3b 52/84: feat: Implement everything planned in the initial spec, ELPA Syncer, 2022/05/03
- [elpa] externals/tomelr 4434ccc64b 70/84: chore: Bump version, ELPA Syncer, 2022/05/03
- [elpa] externals/tomelr 10a1994aed 51/84: feat: Support (lightly tested) nested TOML Table Arrays, ELPA Syncer, 2022/05/03
- [elpa] externals/tomelr df0e73334f 59/84: Revert "doc: Update the medley example", ELPA Syncer, 2022/05/03
- [elpa] externals/tomelr ec381fd723 79/84: fix: Auto-stringify and auto-quote symbol values, ELPA Syncer, 2022/05/03
- [elpa] externals/tomelr a25d952a17 77/84: feat: Auto-coerce string to integers, ELPA Syncer, 2022/05/03
- [elpa] externals/tomelr b2ba4c46b5 82/84: refactor: Minor code reorg, ELPA Syncer, 2022/05/03
- [elpa] externals/tomelr d86fd721ce 63/84: fix: Compatibility for emacs 26.3, ELPA Syncer, 2022/05/03