[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)
- [elpa] externals/tomelr 3c068fb9d9 34/84: refactor: Move TOML Table detection logic to a separate fn, (continued)
- [elpa] externals/tomelr 3c068fb9d9 34/84: refactor: Move TOML Table detection logic to a separate fn, ELPA Syncer, 2022/05/03
- [elpa] externals/tomelr ad8366d904 36/84: feat: Support basic TOML Table Arrays, ELPA Syncer, 2022/05/03
- [elpa] externals/tomelr 55fefb0fa8 40/84: doc: Add few links, ELPA Syncer, 2022/05/03
- [elpa] externals/tomelr 38160ef271 41/84: fix: Stricter condition before starting TOML table array check, ELPA Syncer, 2022/05/03
- [elpa] externals/tomelr a7b3a57037 48/84: feat: Make a very basic nested array of TTA work, ELPA Syncer, 2022/05/03
- [elpa] externals/tomelr 3aa4dc1dbd 54/84: chore: Add Package-Requires and other info in the header comment, ELPA Syncer, 2022/05/03
- [elpa] externals/tomelr f3b6951cfe 53/84: doc: Add note that the scalars need to be earlier in the order, ELPA Syncer, 2022/05/03
- [elpa] externals/tomelr 192cb06a23 57/84: chore(style): Whitespace change only, ELPA Syncer, 2022/05/03
- [elpa] externals/tomelr 6d2be83669 69/84: chore: package-lint fixes, ELPA Syncer, 2022/05/03
- [elpa] externals/tomelr 41ccea4ebe 64/84: refactor: Remove unnecessary tomelr-encode-keyword, ELPA Syncer, 2022/05/03
- [elpa] externals/tomelr 406f4922a8 58/84: test: Add tests for json.el functions used in tomelr,
ELPA Syncer <=
- [elpa] externals/tomelr b3b6a28d15 68/84: doc: Add more examples, ELPA Syncer, 2022/05/03
- [elpa] externals/tomelr f9d670e165 56/84: refactor: Clean up unused code, ELPA Syncer, 2022/05/03
- [elpa] externals/tomelr 511240765b 71/84: chore: Ignore .elc files, ELPA Syncer, 2022/05/03
- [elpa] externals/tomelr ed13b73e9b 74/84: feat: Support string keys, ELPA Syncer, 2022/05/03
- [elpa] externals/tomelr de661716af 72/84: style: Remove space from after and before [ and ] brackets, ELPA Syncer, 2022/05/03
- [elpa] externals/tomelr 334b7cba54 76/84: refactor: Don't attempt to triple-quote TOML keys, ELPA Syncer, 2022/05/03
- [elpa] externals/tomelr c2d1328c44 80/84: fix: Boolean coercing when value is a symbol true or false, ELPA Syncer, 2022/05/03
- [elpa] externals/tomelr ebe5959174 75/84: feat: Auto-coerce string to boolean, ELPA Syncer, 2022/05/03
- [elpa] externals/tomelr a676192b43 81/84: fix: Integer coercing of a number strings with underscores, ELPA Syncer, 2022/05/03
- [elpa] externals/tomelr 8da825067b 15/84: chore(readme): Update, ELPA Syncer, 2022/05/03