diff options
| author | Philipp Stephani | 2016-04-21 14:45:22 -0700 |
|---|---|---|
| committer | Paul Eggert | 2016-04-21 19:29:40 -0700 |
| commit | de7d5f36e0f3261a7300fa3a3d87ae3b758b8a73 (patch) | |
| tree | d929612c6d9ae099782dfe67b2d03041b9395a4f /test | |
| parent | 7621a521452d988b27e761c76ad8e667e932192e (diff) | |
| download | emacs-de7d5f36e0f3261a7300fa3a3d87ae3b758b8a73.tar.gz emacs-de7d5f36e0f3261a7300fa3a3d87ae3b758b8a73.zip | |
Implement named character escapes, similar to Perl
* lread.c (init_character_names): New function.
(read_escape): Read Perl-style named character escape sequences.
(syms_of_lread): Initialize new variable 'character_names'.
* test/src/lread-tests.el (lread-char-empty-name): Add test file
for src/lread.c.
Diffstat (limited to 'test')
| -rw-r--r-- | test/src/lread-tests.el | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/test/src/lread-tests.el b/test/src/lread-tests.el new file mode 100644 index 00000000000..1f873340c56 --- /dev/null +++ b/test/src/lread-tests.el | |||
| @@ -0,0 +1,54 @@ | |||
| 1 | ;;; lread-tests.el --- tests for lread.c -*- lexical-binding: t; -*- | ||
| 2 | |||
| 3 | ;; Copyright (C) 2016 Google Inc. | ||
| 4 | |||
| 5 | ;; Author: Philipp Stephani <phst@google.com> | ||
| 6 | |||
| 7 | ;; This file is part of GNU Emacs. | ||
| 8 | |||
| 9 | ;; This program is free software; you can redistribute it and/or modify | ||
| 10 | ;; it under the terms of the GNU General Public License as published by | ||
| 11 | ;; the Free Software Foundation, either version 3 of the License, or | ||
| 12 | ;; (at your option) any later version. | ||
| 13 | |||
| 14 | ;; This program is distributed in the hope that it will be useful, | ||
| 15 | ;; but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 16 | ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 17 | ;; GNU General Public License for more details. | ||
| 18 | |||
| 19 | ;; You should have received a copy of the GNU General Public License | ||
| 20 | ;; along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
| 21 | |||
| 22 | ;;; Commentary: | ||
| 23 | |||
| 24 | ;; Unit tests for code in src/lread.c. | ||
| 25 | |||
| 26 | ;;; Code: | ||
| 27 | |||
| 28 | (ert-deftest lread-char-number () | ||
| 29 | (should (equal ?\N{U+A817} #xA817))) | ||
| 30 | |||
| 31 | (ert-deftest lread-char-name () | ||
| 32 | (should (equal ?\N{SYLOTI NAGRI LETTER | ||
| 33 | DHO} | ||
| 34 | #xA817))) | ||
| 35 | |||
| 36 | (ert-deftest lread-char-invalid-number () | ||
| 37 | (should-error (read "?\\N{U+110000}") :type 'invalid-read-syntax)) | ||
| 38 | |||
| 39 | (ert-deftest lread-char-invalid-name () | ||
| 40 | (should-error (read "?\\N{DOES NOT EXIST}")) :type 'invalid-read-syntax) | ||
| 41 | |||
| 42 | (ert-deftest lread-char-non-ascii-name () | ||
| 43 | (should-error (read "?\\N{LATIN CAPITAL LETTER Ø}")) 'invalid-read-syntax) | ||
| 44 | |||
| 45 | (ert-deftest lread-char-empty-name () | ||
| 46 | (should-error (read "?\\N{}")) 'invalid-read-syntax) | ||
| 47 | |||
| 48 | (ert-deftest lread-string-char-number () | ||
| 49 | (should (equal "a\N{U+A817}b" "a\uA817b"))) | ||
| 50 | |||
| 51 | (ert-deftest lread-string-char-name () | ||
| 52 | (should (equal "a\N{SYLOTI NAGRI LETTER DHO}b" "a\uA817b"))) | ||
| 53 | |||
| 54 | ;;; lread-tests.el ends here | ||