diff options
| author | Paul Eggert | 2016-04-21 19:26:34 -0700 |
|---|---|---|
| committer | Paul Eggert | 2016-04-21 19:29:41 -0700 |
| commit | bd1c7ca67e7429e07f78d4ff49163fd7a67a6765 (patch) | |
| tree | 941d5cf573be2a4588468b3a315c0c6cb47e2c97 /test/src | |
| parent | e7cb38edc946ff60c1c878b30b068376d6ef56d2 (diff) | |
| download | emacs-bd1c7ca67e7429e07f78d4ff49163fd7a67a6765.tar.gz emacs-bd1c7ca67e7429e07f78d4ff49163fd7a67a6765.zip | |
Improve character name escapes
* doc/lispref/nonascii.texi (Character Properties):
Avoid duplication of Unicode names. Reformat examples to fit in
narrow pages.
* doc/lispref/objects.texi (General Escape Syntax):
Simplify and better-organize explanation of \N{...} escapes.
* src/character.h (CHAR_SURROGATE_PAIR_P): Remove; unused.
(char_surrogate_p): New inline function.
* src/lread.c: Do not include string.h; no longer needed.
(invalid_character_name, check_scalar_value): Remove; the ideas
behind these functions are now bundled into character_name_to_code.
(character_name_to_code): Remove undocumented support for "CJK
IDEOGRAPH-XXXX" names, as "U+XXXX" suffices. Reject monstrosities
like "\N{U+-0}" and null bytes in \N escapes. Reject floating
point in \N escapes instead of returning garbage. Use
AUTO_STRING_WITH_LEN to lessen pressure on the garbage collector.
* test/src/lread-tests.el (lread-char-number, lread-char-name)
(lread-string-char-number, lread-string-char-name):
Test runtime behavior, not compile-time, as the test framework
is not set up to test compile-time.
(lread-char-surrogate-1, lread-char-surrogate-2)
(lread-char-surrogate-3, lread-char-surrogate-4)
(lread-string-char-number-2, lread-string-char-number-3):
New tests.
(lread-string-char-number-1): Rename from lread-string-char-number.
Diffstat (limited to 'test/src')
| -rw-r--r-- | test/src/lread-tests.el | 32 |
1 files changed, 19 insertions, 13 deletions
diff --git a/test/src/lread-tests.el b/test/src/lread-tests.el index ff5d0f655f3..2ebaf491120 100644 --- a/test/src/lread-tests.el +++ b/test/src/lread-tests.el | |||
| @@ -1,6 +1,6 @@ | |||
| 1 | ;;; lread-tests.el --- tests for lread.c -*- lexical-binding: t; -*- | 1 | ;;; lread-tests.el --- tests for lread.c -*- lexical-binding: t; -*- |
| 2 | 2 | ||
| 3 | ;; Copyright (C) 2016 Google Inc. | 3 | ;; Copyright (C) 2016 Free Software Foundation, Inc. |
| 4 | 4 | ||
| 5 | ;; Author: Philipp Stephani <phst@google.com> | 5 | ;; Author: Philipp Stephani <phst@google.com> |
| 6 | 6 | ||
| @@ -26,11 +26,10 @@ | |||
| 26 | ;;; Code: | 26 | ;;; Code: |
| 27 | 27 | ||
| 28 | (ert-deftest lread-char-number () | 28 | (ert-deftest lread-char-number () |
| 29 | (should (equal ?\N{U+A817} #xA817))) | 29 | (should (equal (read "?\\N{U+A817}") #xA817))) |
| 30 | 30 | ||
| 31 | (ert-deftest lread-char-name () | 31 | (ert-deftest lread-char-name () |
| 32 | (should (equal ?\N{SYLOTI NAGRI LETTER | 32 | (should (equal (read "?\\N{SYLOTI NAGRI LETTER \n DHO}") |
| 33 | DHO} | ||
| 34 | #xA817))) | 33 | #xA817))) |
| 35 | 34 | ||
| 36 | (ert-deftest lread-char-invalid-number () | 35 | (ert-deftest lread-char-invalid-number () |
| @@ -46,16 +45,23 @@ | |||
| 46 | (ert-deftest lread-char-empty-name () | 45 | (ert-deftest lread-char-empty-name () |
| 47 | (should-error (read "?\\N{}") :type 'invalid-read-syntax)) | 46 | (should-error (read "?\\N{}") :type 'invalid-read-syntax)) |
| 48 | 47 | ||
| 49 | (ert-deftest lread-char-cjk-name () | 48 | (ert-deftest lread-char-surrogate-1 () |
| 50 | (should (equal ?\N{CJK IDEOGRAPH-2B734} #x2B734))) | 49 | (should-error (read "?\\N{U+D800}") :type 'invalid-read-syntax)) |
| 51 | 50 | (ert-deftest lread-char-surrogate-2 () | |
| 52 | (ert-deftest lread-char-invalid-cjk-name () | 51 | (should-error (read "?\\N{U+D801}") :type 'invalid-read-syntax)) |
| 53 | (should-error (read "?\\N{CJK IDEOGRAPH-2B735}") :type 'invalid-read-syntax)) | 52 | (ert-deftest lread-char-surrogate-3 () |
| 54 | 53 | (should-error (read "?\\N{U+Dffe}") :type 'invalid-read-syntax)) | |
| 55 | (ert-deftest lread-string-char-number () | 54 | (ert-deftest lread-char-surrogate-4 () |
| 56 | (should (equal "a\N{U+A817}b" "a\uA817b"))) | 55 | (should-error (read "?\\N{U+DFFF}") :type 'invalid-read-syntax)) |
| 56 | |||
| 57 | (ert-deftest lread-string-char-number-1 () | ||
| 58 | (should (equal (read "a\\N{U+A817}b") "a\uA817bx"))) | ||
| 59 | (ert-deftest lread-string-char-number-2 () | ||
| 60 | (should-error (read "?\\N{0.5}") :type 'invalid-read-syntax)) | ||
| 61 | (ert-deftest lread-string-char-number-3 () | ||
| 62 | (should-error (read "?\\N{U+-0}") :type 'invalid-read-syntax)) | ||
| 57 | 63 | ||
| 58 | (ert-deftest lread-string-char-name () | 64 | (ert-deftest lread-string-char-name () |
| 59 | (should (equal "a\N{SYLOTI NAGRI LETTER DHO}b" "a\uA817b"))) | 65 | (should (equal (read "a\\N{SYLOTI NAGRI LETTER DHO}b") "a\uA817b"))) |
| 60 | 66 | ||
| 61 | ;;; lread-tests.el ends here | 67 | ;;; lread-tests.el ends here |