diff options
| author | Po Lu | 2024-09-11 13:21:58 +0800 |
|---|---|---|
| committer | Po Lu | 2024-09-11 13:21:58 +0800 |
| commit | 76487b7454b88557d7c8dec7136b7a09aacfb5bf (patch) | |
| tree | 842ee1c5078c962b39f227608fca99ddf9d1ccd3 /test/src | |
| parent | 652a8a0838b38a6eab85c55fc61cedd1c61ef20f (diff) | |
| parent | ee3e3a6311196129104881d6e9097bb54d8843af (diff) | |
| download | emacs-76487b7454b88557d7c8dec7136b7a09aacfb5bf.tar.gz emacs-76487b7454b88557d7c8dec7136b7a09aacfb5bf.zip | |
Merge from savannah/emacs-30
ee3e3a63111 ; Update version number of exec/configure.ac
c5925b6ba5f Fix heex-ts-mode indentation following previews elixir-mo...
c3383be5f04 ; * admin/make-tarball.txt: Improve last change.
8ddb54117f1 ; * admin/make-tarball.txt: Remove now unnecessary config...
7e194d33f90 * lisp/ldefs-boot.el: Update.
9019536ea66 Fix use of Uniscribe font driver in MinGW build
5c55c860db7 Avoid crashes in redisplay in batch-mode testing
ba2190e1ae7 ; * etc/NEWS: Fix indentation.
818c0cc9a51 eglot-test-rust-completion-exit-function: Fix failure in ...
f47297782bd ; * doc/lispref/searching.texi (Rx Notation): Simplify rx...
03e56981675 Clarify the semantics of 'string-pixel-width'
9f0603207b1 ; * src/treesit.c: Minor cleanups of recent changes.
e0d3f743957 * src/treesit.c (treesit_debug_print_parser_list): Fix fo...
bed38ded730 ; * src/treesit.c (treesit_debug_print_parser_list): Fix ...
18c6487dbd0 ; * src/treesit.c: Add a prototype so there's no warning ...
bf23382f1f2 Read more on each call to treesit's buffer reader
3435464452b Fix the range handling in treesit.c
3fcec09f754 Add debugging function for treesit.c
0fd259d166c Fix elixir-ts-mode's range query
2329b36b1fb ; project-files-relative-names: Update docstring (bug#72701)
e55e2e1c6ba Make json-serialize always return a unibyte string (bug#7...
89c99891b2b ; * doc/lispref/os.texi (Suspending Emacs): Fix last change.
4f044d0d3df ; Improve documentation of 'suspend-emacs'
Diffstat (limited to 'test/src')
| -rw-r--r-- | test/src/json-tests.el | 50 |
1 files changed, 26 insertions, 24 deletions
diff --git a/test/src/json-tests.el b/test/src/json-tests.el index ebac70fb1c7..1d7491a4593 100644 --- a/test/src/json-tests.el +++ b/test/src/json-tests.el | |||
| @@ -36,7 +36,7 @@ | |||
| 36 | (json | 36 | (json |
| 37 | "[null,false,true,0,123,-456,3.75,\"abc\uFFFFαβγ𝔸𝐁𝖢\\\"\\\\\"]") | 37 | "[null,false,true,0,123,-456,3.75,\"abc\uFFFFαβγ𝔸𝐁𝖢\\\"\\\\\"]") |
| 38 | (json-bytes (encode-coding-string json 'utf-8))) | 38 | (json-bytes (encode-coding-string json 'utf-8))) |
| 39 | (should (equal (json-serialize lisp) json)) ; or `json-bytes'? | 39 | (should (equal (json-serialize lisp) json-bytes)) |
| 40 | (with-temp-buffer | 40 | (with-temp-buffer |
| 41 | ;; multibyte buffer | 41 | ;; multibyte buffer |
| 42 | (json-insert lisp) | 42 | (json-insert lisp) |
| @@ -82,28 +82,29 @@ | |||
| 82 | "\"abc\uFFFFαβγ𝔸𝐁𝖢\\\"\\\\\""))) | 82 | "\"abc\uFFFFαβγ𝔸𝐁𝖢\\\"\\\\\""))) |
| 83 | (cl-destructuring-bind (lisp json) case | 83 | (cl-destructuring-bind (lisp json) case |
| 84 | (ert-info ((format "%S ↔ %S" lisp json)) | 84 | (ert-info ((format "%S ↔ %S" lisp json)) |
| 85 | (should (equal (json-serialize lisp) json)) | 85 | (let ((json-bytes (encode-coding-string json 'utf-8))) |
| 86 | (with-temp-buffer | 86 | (should (equal (json-serialize lisp) json-bytes)) |
| 87 | (json-insert lisp) | 87 | (with-temp-buffer |
| 88 | (should (equal (buffer-string) json)) | 88 | (json-insert lisp) |
| 89 | (should (eobp))) | 89 | (should (equal (buffer-string) json)) |
| 90 | (with-temp-buffer | 90 | (should (eobp))) |
| 91 | (set-buffer-multibyte nil) | 91 | (with-temp-buffer |
| 92 | (json-insert lisp) | 92 | (set-buffer-multibyte nil) |
| 93 | (should (equal (buffer-string) (encode-coding-string json 'utf-8))) | 93 | (json-insert lisp) |
| 94 | (should (eobp))) | 94 | (should (equal (buffer-string) (encode-coding-string json 'utf-8))) |
| 95 | (should (equal (json-parse-string json) lisp)) | 95 | (should (eobp))) |
| 96 | (with-temp-buffer | 96 | (should (equal (json-parse-string json) lisp)) |
| 97 | (insert json) | 97 | (with-temp-buffer |
| 98 | (goto-char 1) | 98 | (insert json) |
| 99 | (should (equal (json-parse-buffer) lisp)) | 99 | (goto-char 1) |
| 100 | (should (eobp))) | 100 | (should (equal (json-parse-buffer) lisp)) |
| 101 | (with-temp-buffer | 101 | (should (eobp))) |
| 102 | (set-buffer-multibyte nil) | 102 | (with-temp-buffer |
| 103 | (insert (encode-coding-string json 'utf-8)) | 103 | (set-buffer-multibyte nil) |
| 104 | (goto-char 1) | 104 | (insert (encode-coding-string json 'utf-8)) |
| 105 | (should (equal (json-parse-buffer) lisp)) | 105 | (goto-char 1) |
| 106 | (should (eobp))))))) | 106 | (should (equal (json-parse-buffer) lisp)) |
| 107 | (should (eobp)))))))) | ||
| 107 | 108 | ||
| 108 | (ert-deftest json-serialize/object () | 109 | (ert-deftest json-serialize/object () |
| 109 | (let ((table (make-hash-table :test #'equal))) | 110 | (let ((table (make-hash-table :test #'equal))) |
| @@ -226,7 +227,8 @@ | |||
| 226 | (should (equal (json-serialize ["foo"]) "[\"foo\"]")) | 227 | (should (equal (json-serialize ["foo"]) "[\"foo\"]")) |
| 227 | (should (equal (json-serialize ["a\n\fb"]) "[\"a\\n\\fb\"]")) | 228 | (should (equal (json-serialize ["a\n\fb"]) "[\"a\\n\\fb\"]")) |
| 228 | (should (equal (json-serialize ["\nasdфыв\u001f\u007ffgh\t"]) | 229 | (should (equal (json-serialize ["\nasdфыв\u001f\u007ffgh\t"]) |
| 229 | "[\"\\nasdфыв\\u001F\u007ffgh\\t\"]")) | 230 | (encode-coding-string "[\"\\nasdфыв\\u001F\u007ffgh\\t\"]" |
| 231 | 'utf-8))) | ||
| 230 | (should (equal (json-serialize ["a\0b"]) "[\"a\\u0000b\"]")) | 232 | (should (equal (json-serialize ["a\0b"]) "[\"a\\u0000b\"]")) |
| 231 | (should-error (json-serialize ["\xC3\x84"])) | 233 | (should-error (json-serialize ["\xC3\x84"])) |
| 232 | (should-error (json-serialize ["\u00C4\xC3\x84"]))) | 234 | (should-error (json-serialize ["\u00C4\xC3\x84"]))) |