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

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

[elpa] externals/tomelr 406f4922a8 58/84: test: Add tests for json.el fu


From: ELPA Syncer
Subject: [elpa] externals/tomelr 406f4922a8 58/84: test: Add tests for json.el functions used in tomelr
Date: Tue, 3 May 2022 09:58:13 -0400 (EDT)

branch: externals/tomelr
commit 406f4922a8677f07d14190d48061ae60169825d5
Author: Kaushal Modi <kaushal.modi@gmail.com>
Commit: Kaushal Modi <kaushal.modi@gmail.com>

    test: Add tests for json.el functions used in tomelr
---
 test/all-tests.el   |  1 +
 test/tjson-utils.el | 81 +++++++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 82 insertions(+)

diff --git a/test/all-tests.el b/test/all-tests.el
index 45c5442ab4..adab51f609 100644
--- a/test/all-tests.el
+++ b/test/all-tests.el
@@ -21,6 +21,7 @@
 
 (setq load-prefer-newer t)
 
+(require 'tjson-utils)
 (require 'tinternal)
 
 (require 'tscalar)
diff --git a/test/tjson-utils.el b/test/tjson-utils.el
new file mode 100644
index 0000000000..4cf6e9d2e5
--- /dev/null
+++ b/test/tjson-utils.el
@@ -0,0 +1,81 @@
+;; -*- lexical-binding: t; -*-
+
+;; Authors: Kaushal Modi <kaushal.modi@gmail.com>
+
+;; This file is not part of GNU Emacs.
+
+;; This program is free software; you can redistribute it and/or modify
+;; it under the terms of the GNU General Public License as published by
+;; the Free Software Foundation, either version 3 of the License, or
+;; (at your option) any later version.
+
+;; This program is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+;; GNU General Public License for more details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with this program.  If not, see <https://www.gnu.org/licenses/>.
+
+;;; Commentary:
+
+;; Tests for json.el functions used in tomelr.
+
+;;; Code:
+(require 'tomelr)
+
+;;;; json-alist-p (TOML Tables)
+(ert-deftest test-internal-json-alist-p-true ()
+  (let ((inp '(
+               ((a . 1))
+               ((a . 1) (b . 2))
+               ;; Nested TT
+               ((a . 1)
+                (b . ((c . 3)
+                      (d . 4))))
+               ;; Nested TTA
+               ((a . 1)
+                (b . (((c . 3))
+                      ((c . 300)))))
+               )))
+    (dolist (el inp)
+      (should (equal t (json-alist-p el))))))
+
+(ert-deftest test-internal-json-alist-p-false ()
+  (let ((inp '(
+               (a 1)
+               ;; FIXME: `json-alist-p' returns non-nil for below TTA as well.
+               ;; ((:a 1))                ;This is an array of TOML table
+               (((a . 1)))             ;This is an array of TOML table
+               )))
+    (dolist (el inp)
+      (should (equal nil (json-alist-p el))))))
+
+;;;; json-plist-p (TOML Tables)
+(ert-deftest test-internal-json-plist-p-true ()
+  (let ((inp '(
+               (:a 1)
+               (:a 1 :b 2)
+               ;; Nested TT
+               (:a 1
+                :b (:c 3
+                    :d 4))
+               ;; Nested TTA
+               (:a 1
+                :b ((:c 3)
+                    (:c 300)))
+               )))
+    (dolist (el inp)
+      (should (equal t (json-plist-p el))))))
+
+(ert-deftest test-internal-json-plist-p-false ()
+  (let ((inp '(
+               (a 1)
+               ((:a 1))                ;This is an array of TOML table
+               (((a . 1)))             ;This is an array of TOML table
+               )))
+    (dolist (el inp)
+      (should (equal nil (json-plist-p el))))))
+
+
+(provide 'tjson-utils)



reply via email to

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