1 ;;; lread-tests.el --- tests for lread.c -*- lexical-binding: t; -*-
3 ;; Copyright (C) 2016 Free Software Foundation, Inc.
5 ;; Author: Philipp Stephani <phst@google.com>
7 ;; This file is part of GNU Emacs.
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.
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.
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/>.
24 ;; Unit tests for code in src/lread.c.
28 (ert-deftest lread-char-number
()
29 (should (equal (read "?\\N{U+A817}") #xA817
)))
31 (ert-deftest lread-char-name-1
()
32 (should (equal (read "?\\N{SYLOTI NAGRI LETTER \n DHO}")
34 (ert-deftest lread-char-name-2
()
35 (should (equal (read "?\\N{BED}") #x1F6CF
)))
36 (ert-deftest lread-char-name-3
()
37 (should (equal (read "?\\N{U+BED}") #xBED
)))
38 (ert-deftest lread-char-name-4
()
39 (should (equal (read "?\\N{VARIATION SELECTOR-1}") #xFE00
)))
40 (ert-deftest lread-char-name-5
()
41 (should (equal (read "?\\N{VARIATION SELECTOR-16}") #xFE0F
)))
42 (ert-deftest lread-char-name-6
()
43 (should (equal (read "?\\N{VARIATION SELECTOR-17}") #xE0100
)))
44 (ert-deftest lread-char-name-7
()
45 (should (equal (read "?\\N{VARIATION SELECTOR-256}") #xE01EF
)))
46 (ert-deftest lread-char-name-8
()
47 (should (equal (read "?\\N{CJK COMPATIBILITY IDEOGRAPH-F900}") #xF900
)))
48 (ert-deftest lread-char-name-9
()
49 (should (equal (read "?\\N{CJK COMPATIBILITY IDEOGRAPH-FAD9}") #xFAD9
)))
50 (ert-deftest lread-char-name-10
()
51 (should (equal (read "?\\N{CJK COMPATIBILITY IDEOGRAPH-2F800}") #x2F800
)))
52 (ert-deftest lread-char-name-11
()
53 (should (equal (read "?\\N{CJK COMPATIBILITY IDEOGRAPH-2FA1D}") #x2FA1D
)))
55 (ert-deftest lread-char-invalid-number
()
56 (should-error (read "?\\N{U+110000}") :type
'invalid-read-syntax
))
58 (ert-deftest lread-char-invalid-name-1
()
59 (should-error (read "?\\N{DOES NOT EXIST}")) :type
'invalid-read-syntax
)
60 (ert-deftest lread-char-invalid-name-2
()
61 (should-error (read "?\\N{VARIATION SELECTOR-0}")) :type
'invalid-read-syntax
)
62 (ert-deftest lread-char-invalid-name-3
()
63 (should-error (read "?\\N{VARIATION SELECTOR-257}"))
64 :type
'invalid-read-syntax
)
65 (ert-deftest lread-char-invalid-name-4
()
66 (should-error (read "?\\N{VARIATION SELECTOR--0}"))
67 :type
'invalid-read-syntax
)
68 (ert-deftest lread-char-invalid-name-5
()
69 (should-error (read "?\\N{CJK COMPATIBILITY IDEOGRAPH-F8FF}"))
70 :type
'invalid-read-syntax
)
71 (ert-deftest lread-char-invalid-name-6
()
72 (should-error (read "?\\N{CJK COMPATIBILITY IDEOGRAPH-FADA}"))
73 :type
'invalid-read-syntax
)
74 (ert-deftest lread-char-invalid-name-7
()
75 (should-error (read "?\\N{CJK COMPATIBILITY IDEOGRAPH-2F7FF}"))
76 :type
'invalid-read-syntax
)
77 (ert-deftest lread-char-invalid-name-8
()
78 (should-error (read "?\\N{CJK COMPATIBILITY IDEOGRAPH-2FA1E}"))
79 :type
'invalid-read-syntax
)
81 (ert-deftest lread-char-non-ascii-name
()
82 (should-error (read "?\\N{LATIN CAPITAL LETTER Ø}")
83 :type
'invalid-read-syntax
))
85 (ert-deftest lread-char-empty-name
()
86 (should-error (read "?\\N{}") :type
'invalid-read-syntax
))
88 (ert-deftest lread-char-surrogate-1
()
89 (should-error (read "?\\N{U+D800}") :type
'invalid-read-syntax
))
90 (ert-deftest lread-char-surrogate-2
()
91 (should-error (read "?\\N{U+D801}") :type
'invalid-read-syntax
))
92 (ert-deftest lread-char-surrogate-3
()
93 (should-error (read "?\\N{U+Dffe}") :type
'invalid-read-syntax
))
94 (ert-deftest lread-char-surrogate-4
()
95 (should-error (read "?\\N{U+DFFF}") :type
'invalid-read-syntax
))
97 (ert-deftest lread-string-char-number-1
()
98 (should (equal (read "\"a\\N{U+A817}b\"") "a\uA817b")))
99 (ert-deftest lread-string-char-number-2
()
100 (should-error (read "?\\N{0.5}") :type
'invalid-read-syntax
))
101 (ert-deftest lread-string-char-number-3
()
102 (should-error (read "?\\N{U+-0}") :type
'invalid-read-syntax
))
104 (ert-deftest lread-string-char-name
()
105 (should (equal (read "\"a\\N{SYLOTI NAGRI LETTER DHO}b\"") "a\uA817b")))
107 ;;; lread-tests.el ends here