all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Dmitry Gutov <dgutov@yandex.ru>
To: Yoichi Nakayama <yoichi.nakayama@gmail.com>
Cc: 24252@debbugs.gnu.org
Subject: bug#24252: 25.1; json.el doesn't distinguish null and empty object
Date: Sat, 27 Aug 2016 03:05:41 +0300	[thread overview]
Message-ID: <809ddc8d-8cd1-387b-fec6-fec60e0bd9c9@yandex.ru> (raw)
In-Reply-To: <CAF5D8-tX5TPZpsD2gCG+JQBfF2mgLqrVW-PmH5PkgFvXEeBZPg@mail.gmail.com>

Hi Yoichi,

Thanks, but the changes to tests like below seem to indicate that the 
code breaks backward compatibility in certain respect. I'm not sure 
we'll want to merge it for that reason.

I'd like to know what other developers think.

On 08/21/2016 06:06 PM, Yoichi Nakayama wrote:

>  (ert-deftest test-json-plist-to-alist ()
>    (should (equal (json--plist-to-alist '()) '()))
> -  (should (equal (json--plist-to-alist '(:a 1)) '((:a . 1))))
> +  (should (equal (json--plist-to-alist '(:a 1)) '((a . 1))))
> +  (let ((json-key-type 'keyword))
> +    (should (equal (json--plist-to-alist '(:a 1)) '((:a . 1)))))
>    (should (equal (json--plist-to-alist '(:a 1 :b 2 :c 3))
> -                 '((:a . 1) (:b . 2) (:c . 3)))))
> +                 '((a . 1) (b . 2) (c . 3)))))
>
>  (ert-deftest test-json-advance ()
>    (json-tests--with-temp-buffer "{ \"a\": 1 }"
> @@ -177,9 +179,16 @@ Point is moved to beginning of the buffer."
>                   "\"\\nasdфыв\\u001f\u007ffgh\\t\"")))
>
>  (ert-deftest test-json-encode-key ()
> -  (should (equal (json-encode-key "foo") "\"foo\""))
> -  (should (equal (json-encode-key 'foo) "\"foo\""))
> -  (should (equal (json-encode-key :foo) "\"foo\""))
> +  (let ((json-key-type 'string))
> +    (should (equal (json-encode-key "foo") "\"foo\""))
> +    (should-error (json-encode-key t) :type 'json-key-format))
> +  (let ((json-key-type 'symbol))
> +    (should (equal (json-encode-key 'foo) "\"foo\""))
> +    (should (equal (json-encode-key t) "\"t\""))
> +    (should (equal (json-encode-key :t) "\":t\"")))
> +  (let ((json-key-type 'keyword))
> +    (should (equal (json-encode-key :foo) "\"foo\""))
> +    (should-error (json-encode-key t) :type 'json-key-format))
>    (should-error (json-encode-key 5) :type 'json-key-format)
>    (should-error (json-encode-key ["foo"]) :type 'json-key-format)
>    (should-error (json-encode-key '("foo")) :type 'json-key-format))
> @@ -238,9 +247,9 @@ Point is moved to beginning of the buffer."
>    (let ((hash-table (make-hash-table))
>          (json-encoding-object-sort-predicate 'string<)
>          (json-encoding-pretty-print nil))
> -    (puthash :a 1 hash-table)
> -    (puthash :b 2 hash-table)
> -    (puthash :c 3 hash-table)
> +    (puthash "a" 1 hash-table)
> +    (puthash "b" 2 hash-table)
> +    (puthash "c" 3 hash-table)
>      (should (equal (json-encode hash-table)
>                     "{\"a\":1,\"b\":2,\"c\":3}"))))
>
> @@ -261,7 +270,7 @@ Point is moved to beginning of the buffer."
>      (should (equal (json-encode plist) "{\"a\":1,\"b\":2,\"c\":3}"))))
>
>  (ert-deftest test-json-encode-alist-with-sort-predicate ()
> -  (let ((alist '((:c . 3) (:a . 1) (:b . 2)))
> +  (let ((alist '((c . 3) (a . 1) (b . 2)))
>          (json-encoding-object-sort-predicate 'string<)
>          (json-encoding-pretty-print nil))
>      (should (equal (json-encode alist) "{\"a\":1,\"b\":2,\"c\":3}"))))
> @@ -270,7 +279,7 @@ Point is moved to beginning of the buffer."
>    (let ((json-encoding-pretty-print nil))
>      (should (equal (json-encode-list '(:a 1 :b 2))
>                     "{\"a\":1,\"b\":2}"))
> -    (should (equal (json-encode-list '((:a . 1) (:b . 2)))
> +    (should (equal (json-encode-list '((a . 1) (b . 2)))
>                     "{\"a\":1,\"b\":2}"))
>      (should (equal (json-encode-list '(1 2 3 4)) "[1,2,3,4]"))))






  reply	other threads:[~2016-08-27  0:05 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-08-17 14:54 bug#24252: 25.1; json.el doesn't distinguish null and empty object Yoichi Nakayama
2016-08-19  2:06 ` Dmitry Gutov
2016-08-19 23:45   ` Yoichi Nakayama
2016-08-20  0:52     ` Dmitry Gutov
2016-08-20  6:12       ` Yoichi Nakayama
2016-08-21  1:30         ` Yoichi Nakayama
2016-08-21  3:42         ` Dmitry Gutov
2016-08-21 12:11           ` Yoichi Nakayama
2016-08-21 13:32             ` Yoichi Nakayama
2016-08-21 15:06               ` Yoichi Nakayama
2016-08-27  0:05                 ` Dmitry Gutov [this message]
2018-05-17 14:39                 ` Damien Cassou
2018-05-19  6:52 ` Damien Cassou
2018-05-28 15:21   ` Nicolas Petton
2018-06-11 13:36     ` Damien Cassou
2018-06-12 17:14       ` Eli Zaretskii
2018-06-13  7:13         ` Damien Cassou
2018-06-13 13:05           ` Nicolas Petton
2018-06-13 16:55             ` Eli Zaretskii
2018-06-14  9:04               ` Nicolas Petton

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=809ddc8d-8cd1-387b-fec6-fec60e0bd9c9@yandex.ru \
    --to=dgutov@yandex.ru \
    --cc=24252@debbugs.gnu.org \
    --cc=yoichi.nakayama@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.