annotate tests/automated/mule-tests.el @ 5664:00fd55d635fb

Sync #'truncate-string-to-width with GNU, add tests for it. lisp/ChangeLog addition: 2012-05-12 Aidan Kehoe <kehoea@parhasard.net> * subr.el: * subr.el (truncate-string-to-width): Sync with GNU's version, use its test suite in mule-tests.el. tests/ChangeLog addition: 2012-05-12 Aidan Kehoe <kehoea@parhasard.net> * automated/mule-tests.el: Test #'truncate-string-to-width, thank you Colin Walters.
author Aidan Kehoe <kehoea@parhasard.net>
date Sat, 12 May 2012 17:51:05 +0100
parents 391d809fa4e9
children 15041705c196
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1 ;; Copyright (C) 1999 Free Software Foundation, Inc.
5136
0f66906b6e37 Undo Assert-equal, Assert=, etc.; make `Assert' handle this automatically
Ben Wing <ben@xemacs.org>
parents: 5107
diff changeset
2 ;; Copyright (C) 2010 Ben Wing.
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4 ;; Author: Hrvoje Niksic <hniksic@xemacs.org>
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 438
diff changeset
5 ;; Maintainers: Hrvoje Niksic <hniksic@xemacs.org>,
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 438
diff changeset
6 ;; Martin Buchholz <martin@xemacs.org>
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
7 ;; Created: 1999
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
8 ;; Keywords: tests
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
9
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
10 ;; This file is part of XEmacs.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
11
5402
308d34e9f07d Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents: 5136
diff changeset
12 ;; XEmacs is free software: you can redistribute it and/or modify it
308d34e9f07d Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents: 5136
diff changeset
13 ;; under the terms of the GNU General Public License as published by the
308d34e9f07d Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents: 5136
diff changeset
14 ;; Free Software Foundation, either version 3 of the License, or (at your
308d34e9f07d Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents: 5136
diff changeset
15 ;; option) any later version.
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
16
5402
308d34e9f07d Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents: 5136
diff changeset
17 ;; XEmacs is distributed in the hope that it will be useful, but WITHOUT
308d34e9f07d Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents: 5136
diff changeset
18 ;; ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
308d34e9f07d Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents: 5136
diff changeset
19 ;; FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
308d34e9f07d Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents: 5136
diff changeset
20 ;; for more details.
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
21
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
22 ;; You should have received a copy of the GNU General Public License
5402
308d34e9f07d Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents: 5136
diff changeset
23 ;; along with XEmacs. If not, see <http://www.gnu.org/licenses/>.
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
24
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
25 ;;; Synched up with: Not in FSF.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
26
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
27 ;;; Commentary:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
28
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
29 ;; Test some Mule functionality (most of these remain to be written) .
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
30 ;; See test-harness.el for instructions on how to run these tests.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
31
434
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 428
diff changeset
32 ;; This file will be (read)ed by a non-mule XEmacs, so don't use
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 428
diff changeset
33 ;; literal non-Latin1 characters. Use (make-char) instead.
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 428
diff changeset
34
3948
adecfd791c9b [xemacs-hg @ 2007-05-12 10:17:00 by aidan]
aidan
parents: 3927
diff changeset
35 (require 'bytecomp)
adecfd791c9b [xemacs-hg @ 2007-05-12 10:17:00 by aidan]
aidan
parents: 3927
diff changeset
36
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
37 ;;-----------------------------------------------------------------
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
38 ;; Test whether all legal chars may be safely inserted to a buffer.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
39 ;;-----------------------------------------------------------------
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
40
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
41 (defun test-chars (&optional for-test-harness)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
42 "Insert all characters in a buffer, to see if XEmacs will crash.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
43 This is done by creating a string with all the legal characters
4133
5b55fa103aa1 [xemacs-hg @ 2007-08-21 12:38:57 by aidan]
aidan
parents: 4026
diff changeset
44 in [0, 2^21) range, inserting it into the buffer, and checking
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
45 that the buffer's contents are equivalent to the string.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
46
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
47 If FOR-TEST-HARNESS is specified, a temporary buffer is used, and
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
48 the Assert macro checks for correctness."
4133
5b55fa103aa1 [xemacs-hg @ 2007-08-21 12:38:57 by aidan]
aidan
parents: 4026
diff changeset
49 (let ((max (expt 2 (if (featurep 'mule) 21 8)))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
50 (list nil)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
51 (i 0))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
52 (while (< i max)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
53 (and (not for-test-harness)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
54 (zerop (% i 1000))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
55 (message "%d" i))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
56 (and (int-char i)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
57 ;; Don't aset to a string directly because random string
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
58 ;; access is O(n) under Mule.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
59 (setq list (cons (int-char i) list)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
60 (setq i (1+ i)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
61 (let ((string (apply #'string (nreverse list))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
62 (if for-test-harness
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
63 ;; For use with test-harness, use Assert and a temporary
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
64 ;; buffer.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
65 (with-temp-buffer
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
66 (insert string)
5136
0f66906b6e37 Undo Assert-equal, Assert=, etc.; make `Assert' handle this automatically
Ben Wing <ben@xemacs.org>
parents: 5107
diff changeset
67 (Assert (equal (buffer-string) string)))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
68 ;; For use without test harness: use a normal buffer, so that
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
69 ;; you can also test whether redisplay works.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
70 (switch-to-buffer (get-buffer-create "test"))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
71 (erase-buffer)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
72 (buffer-disable-undo)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
73 (insert string)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
74 (assert (equal (buffer-string) string))))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
75
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
76 ;; It would be really *really* nice if test-harness allowed a way to
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
77 ;; run a test in byte-compiled mode only. It's tedious to have
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
78 ;; time-consuming tests like this one run twice, once interpreted and
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
79 ;; once compiled, for no good reason.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
80 (test-chars t)
434
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 428
diff changeset
81
3439
d1754e7f0cea [xemacs-hg @ 2006-06-03 17:50:39 by aidan]
aidan
parents: 2026
diff changeset
82 (defun unicode-code-point-to-utf-8-string (code-point)
d1754e7f0cea [xemacs-hg @ 2006-06-03 17:50:39 by aidan]
aidan
parents: 2026
diff changeset
83 "Convert a Unicode code point to the equivalent UTF-8 string.
d1754e7f0cea [xemacs-hg @ 2006-06-03 17:50:39 by aidan]
aidan
parents: 2026
diff changeset
84 This is a naive implementation in Lisp. "
d1754e7f0cea [xemacs-hg @ 2006-06-03 17:50:39 by aidan]
aidan
parents: 2026
diff changeset
85 (check-argument-type 'natnump code-point)
d1754e7f0cea [xemacs-hg @ 2006-06-03 17:50:39 by aidan]
aidan
parents: 2026
diff changeset
86 (check-argument-range code-point 0 #x1fffff)
d1754e7f0cea [xemacs-hg @ 2006-06-03 17:50:39 by aidan]
aidan
parents: 2026
diff changeset
87 (if (< code-point #x80)
d1754e7f0cea [xemacs-hg @ 2006-06-03 17:50:39 by aidan]
aidan
parents: 2026
diff changeset
88 (format "%c" code-point)
d1754e7f0cea [xemacs-hg @ 2006-06-03 17:50:39 by aidan]
aidan
parents: 2026
diff changeset
89 (if (< code-point #x800)
d1754e7f0cea [xemacs-hg @ 2006-06-03 17:50:39 by aidan]
aidan
parents: 2026
diff changeset
90 (format "%c%c"
d1754e7f0cea [xemacs-hg @ 2006-06-03 17:50:39 by aidan]
aidan
parents: 2026
diff changeset
91 ;; ochars[0] = 0xC0 | (input & ~(0xFFFFF83F)) >> 6;
d1754e7f0cea [xemacs-hg @ 2006-06-03 17:50:39 by aidan]
aidan
parents: 2026
diff changeset
92 (logior #xc0 (lsh (logand code-point #x7c0) -6))
d1754e7f0cea [xemacs-hg @ 2006-06-03 17:50:39 by aidan]
aidan
parents: 2026
diff changeset
93 ;; ochars[1] = 0x80 | input & ~(0xFFFFFFC0);
d1754e7f0cea [xemacs-hg @ 2006-06-03 17:50:39 by aidan]
aidan
parents: 2026
diff changeset
94 (logior #x80 (logand code-point #x3f)))
d1754e7f0cea [xemacs-hg @ 2006-06-03 17:50:39 by aidan]
aidan
parents: 2026
diff changeset
95 (if (< code-point #x00010000)
d1754e7f0cea [xemacs-hg @ 2006-06-03 17:50:39 by aidan]
aidan
parents: 2026
diff changeset
96 (format "%c%c%c"
d1754e7f0cea [xemacs-hg @ 2006-06-03 17:50:39 by aidan]
aidan
parents: 2026
diff changeset
97 ;; ochars[0] = 0xE0 | (input >> 12) & ~(0xFFFFFFF0);
d1754e7f0cea [xemacs-hg @ 2006-06-03 17:50:39 by aidan]
aidan
parents: 2026
diff changeset
98 (logior #xe0 (logand (lsh code-point -12) #x0f))
d1754e7f0cea [xemacs-hg @ 2006-06-03 17:50:39 by aidan]
aidan
parents: 2026
diff changeset
99 ;; ochars[1] = 0x80 | (input >> 6) & ~(0xFFFFFFC0);
d1754e7f0cea [xemacs-hg @ 2006-06-03 17:50:39 by aidan]
aidan
parents: 2026
diff changeset
100 (logior #x80 (logand (lsh code-point -6) #x3f))
d1754e7f0cea [xemacs-hg @ 2006-06-03 17:50:39 by aidan]
aidan
parents: 2026
diff changeset
101 ;; ochars[2] = 0x80 | input & ~(0xFFFFFFC0);
d1754e7f0cea [xemacs-hg @ 2006-06-03 17:50:39 by aidan]
aidan
parents: 2026
diff changeset
102 (logior #x80 (logand code-point #x3f)))
d1754e7f0cea [xemacs-hg @ 2006-06-03 17:50:39 by aidan]
aidan
parents: 2026
diff changeset
103 (if (< code-point #x200000)
d1754e7f0cea [xemacs-hg @ 2006-06-03 17:50:39 by aidan]
aidan
parents: 2026
diff changeset
104 (format "%c%c%c%c"
d1754e7f0cea [xemacs-hg @ 2006-06-03 17:50:39 by aidan]
aidan
parents: 2026
diff changeset
105 ;; ochars[0] = 0xF0 | (input >> 18) & ~(0xFFFFFFF8)
d1754e7f0cea [xemacs-hg @ 2006-06-03 17:50:39 by aidan]
aidan
parents: 2026
diff changeset
106 (logior #xF0 (logand (lsh code-point -18) #x7))
d1754e7f0cea [xemacs-hg @ 2006-06-03 17:50:39 by aidan]
aidan
parents: 2026
diff changeset
107 ;; ochars[1] = 0x80 | (input >> 12) & ~(0xFFFFFFC0);
d1754e7f0cea [xemacs-hg @ 2006-06-03 17:50:39 by aidan]
aidan
parents: 2026
diff changeset
108 (logior #x80 (logand (lsh code-point -12) #x3f))
d1754e7f0cea [xemacs-hg @ 2006-06-03 17:50:39 by aidan]
aidan
parents: 2026
diff changeset
109 ;; ochars[2] = 0x80 | (input >> 6) & ~(0xFFFFFFC0);
d1754e7f0cea [xemacs-hg @ 2006-06-03 17:50:39 by aidan]
aidan
parents: 2026
diff changeset
110 (logior #x80 (logand (lsh code-point -6) #x3f))
d1754e7f0cea [xemacs-hg @ 2006-06-03 17:50:39 by aidan]
aidan
parents: 2026
diff changeset
111 ;; ochars[3] = 0x80 | input & ~(0xFFFFFFC0);
d1754e7f0cea [xemacs-hg @ 2006-06-03 17:50:39 by aidan]
aidan
parents: 2026
diff changeset
112 (logior #x80 (logand code-point #x3f))))))))
d1754e7f0cea [xemacs-hg @ 2006-06-03 17:50:39 by aidan]
aidan
parents: 2026
diff changeset
113
4026
4d60c2708e5d [xemacs-hg @ 2007-06-22 16:37:37 by stephent]
stephent
parents: 3976
diff changeset
114 ;;----------------------------------------------------------------
4d60c2708e5d [xemacs-hg @ 2007-06-22 16:37:37 by stephent]
stephent
parents: 3976
diff changeset
115 ;; Test that revert-buffer resets the modiff
4d60c2708e5d [xemacs-hg @ 2007-06-22 16:37:37 by stephent]
stephent
parents: 3976
diff changeset
116 ;; Bug reported 2007-06-20 <200706201902.32191.scop@xemacs.org>.
4d60c2708e5d [xemacs-hg @ 2007-06-22 16:37:37 by stephent]
stephent
parents: 3976
diff changeset
117 ;; Fixed 2007-06-22 <18043.2793.611745.734215@parhasard.net>.
4d60c2708e5d [xemacs-hg @ 2007-06-22 16:37:37 by stephent]
stephent
parents: 3976
diff changeset
118 ;;----------------------------------------------------------------
4d60c2708e5d [xemacs-hg @ 2007-06-22 16:37:37 by stephent]
stephent
parents: 3976
diff changeset
119
4399
e5b3c4dbc8a2 Call #'make-temp-file in mule-tests.el, now it's available.
Aidan Kehoe <kehoea@parhasard.net>
parents: 4318
diff changeset
120 (let ((test-file-name
e5b3c4dbc8a2 Call #'make-temp-file in mule-tests.el, now it's available.
Aidan Kehoe <kehoea@parhasard.net>
parents: 4318
diff changeset
121 (make-temp-file (expand-file-name "tXfXsKc" (temp-directory))))
4026
4d60c2708e5d [xemacs-hg @ 2007-06-22 16:37:37 by stephent]
stephent
parents: 3976
diff changeset
122 revert-buffer-function
4d60c2708e5d [xemacs-hg @ 2007-06-22 16:37:37 by stephent]
stephent
parents: 3976
diff changeset
123 kill-buffer-hook) ; paranoia
4d60c2708e5d [xemacs-hg @ 2007-06-22 16:37:37 by stephent]
stephent
parents: 3976
diff changeset
124 (find-file test-file-name)
4d60c2708e5d [xemacs-hg @ 2007-06-22 16:37:37 by stephent]
stephent
parents: 3976
diff changeset
125 (erase-buffer)
4d60c2708e5d [xemacs-hg @ 2007-06-22 16:37:37 by stephent]
stephent
parents: 3976
diff changeset
126 (insert "a string\n")
4133
5b55fa103aa1 [xemacs-hg @ 2007-08-21 12:38:57 by aidan]
aidan
parents: 4026
diff changeset
127 (Silence-Message (save-buffer 0))
4026
4d60c2708e5d [xemacs-hg @ 2007-06-22 16:37:37 by stephent]
stephent
parents: 3976
diff changeset
128 (insert "more text\n")
4d60c2708e5d [xemacs-hg @ 2007-06-22 16:37:37 by stephent]
stephent
parents: 3976
diff changeset
129 (revert-buffer t t)
4d60c2708e5d [xemacs-hg @ 2007-06-22 16:37:37 by stephent]
stephent
parents: 3976
diff changeset
130 ;; Just "find-file" with autodetect coding didn't fail for me, but it does
4d60c2708e5d [xemacs-hg @ 2007-06-22 16:37:37 by stephent]
stephent
parents: 3976
diff changeset
131 ;; fail under test harness. Still we'll redo the test with an explicit
4d60c2708e5d [xemacs-hg @ 2007-06-22 16:37:37 by stephent]
stephent
parents: 3976
diff changeset
132 ;; coding system just in case.
4d60c2708e5d [xemacs-hg @ 2007-06-22 16:37:37 by stephent]
stephent
parents: 3976
diff changeset
133 (Assert (not (buffer-modified-p)))
4d60c2708e5d [xemacs-hg @ 2007-06-22 16:37:37 by stephent]
stephent
parents: 3976
diff changeset
134 (kill-buffer nil)
4d60c2708e5d [xemacs-hg @ 2007-06-22 16:37:37 by stephent]
stephent
parents: 3976
diff changeset
135 (when (find-coding-system 'utf-8)
4d60c2708e5d [xemacs-hg @ 2007-06-22 16:37:37 by stephent]
stephent
parents: 3976
diff changeset
136 (find-file test-file-name 'utf-8)
4d60c2708e5d [xemacs-hg @ 2007-06-22 16:37:37 by stephent]
stephent
parents: 3976
diff changeset
137 (insert "more text\n")
4d60c2708e5d [xemacs-hg @ 2007-06-22 16:37:37 by stephent]
stephent
parents: 3976
diff changeset
138 (revert-buffer t t)
4d60c2708e5d [xemacs-hg @ 2007-06-22 16:37:37 by stephent]
stephent
parents: 3976
diff changeset
139 (Assert (not (buffer-modified-p)))
4d60c2708e5d [xemacs-hg @ 2007-06-22 16:37:37 by stephent]
stephent
parents: 3976
diff changeset
140 (kill-buffer nil))
4d60c2708e5d [xemacs-hg @ 2007-06-22 16:37:37 by stephent]
stephent
parents: 3976
diff changeset
141 (delete-file test-file-name))
4d60c2708e5d [xemacs-hg @ 2007-06-22 16:37:37 by stephent]
stephent
parents: 3976
diff changeset
142
4647
e4ed58cb0e5b Fix bugs with #'find-file, 0-length files, & coding-system-for-read specified.
Aidan Kehoe <kehoea@parhasard.net>
parents: 4623
diff changeset
143 (let ((existing-file-name
e4ed58cb0e5b Fix bugs with #'find-file, 0-length files, & coding-system-for-read specified.
Aidan Kehoe <kehoea@parhasard.net>
parents: 4623
diff changeset
144 (make-temp-file (expand-file-name "k7lCS2Mg" (temp-directory))))
e4ed58cb0e5b Fix bugs with #'find-file, 0-length files, & coding-system-for-read specified.
Aidan Kehoe <kehoea@parhasard.net>
parents: 4623
diff changeset
145 (nonexistent-file-name
e4ed58cb0e5b Fix bugs with #'find-file, 0-length files, & coding-system-for-read specified.
Aidan Kehoe <kehoea@parhasard.net>
parents: 4623
diff changeset
146 (make-temp-name (temp-directory))))
e4ed58cb0e5b Fix bugs with #'find-file, 0-length files, & coding-system-for-read specified.
Aidan Kehoe <kehoea@parhasard.net>
parents: 4623
diff changeset
147 (find-file existing-file-name)
e4ed58cb0e5b Fix bugs with #'find-file, 0-length files, & coding-system-for-read specified.
Aidan Kehoe <kehoea@parhasard.net>
parents: 4623
diff changeset
148 (Assert (not (eq 'undecided
e4ed58cb0e5b Fix bugs with #'find-file, 0-length files, & coding-system-for-read specified.
Aidan Kehoe <kehoea@parhasard.net>
parents: 4623
diff changeset
149 (coding-system-type buffer-file-coding-system))))
e4ed58cb0e5b Fix bugs with #'find-file, 0-length files, & coding-system-for-read specified.
Aidan Kehoe <kehoea@parhasard.net>
parents: 4623
diff changeset
150 (kill-buffer nil)
e4ed58cb0e5b Fix bugs with #'find-file, 0-length files, & coding-system-for-read specified.
Aidan Kehoe <kehoea@parhasard.net>
parents: 4623
diff changeset
151 (dolist (coding-system '(utf-8 windows-1251 macintosh big5))
e4ed58cb0e5b Fix bugs with #'find-file, 0-length files, & coding-system-for-read specified.
Aidan Kehoe <kehoea@parhasard.net>
parents: 4623
diff changeset
152 (when (find-coding-system coding-system)
e4ed58cb0e5b Fix bugs with #'find-file, 0-length files, & coding-system-for-read specified.
Aidan Kehoe <kehoea@parhasard.net>
parents: 4623
diff changeset
153 (find-file existing-file-name coding-system)
5136
0f66906b6e37 Undo Assert-equal, Assert=, etc.; make `Assert' handle this automatically
Ben Wing <ben@xemacs.org>
parents: 5107
diff changeset
154 (Assert (eq (find-coding-system coding-system)
0f66906b6e37 Undo Assert-equal, Assert=, etc.; make `Assert' handle this automatically
Ben Wing <ben@xemacs.org>
parents: 5107
diff changeset
155 buffer-file-coding-system))
4647
e4ed58cb0e5b Fix bugs with #'find-file, 0-length files, & coding-system-for-read specified.
Aidan Kehoe <kehoea@parhasard.net>
parents: 4623
diff changeset
156 (kill-buffer nil)
e4ed58cb0e5b Fix bugs with #'find-file, 0-length files, & coding-system-for-read specified.
Aidan Kehoe <kehoea@parhasard.net>
parents: 4623
diff changeset
157 (find-file nonexistent-file-name coding-system)
5136
0f66906b6e37 Undo Assert-equal, Assert=, etc.; make `Assert' handle this automatically
Ben Wing <ben@xemacs.org>
parents: 5107
diff changeset
158 (Assert (eq (find-coding-system coding-system)
0f66906b6e37 Undo Assert-equal, Assert=, etc.; make `Assert' handle this automatically
Ben Wing <ben@xemacs.org>
parents: 5107
diff changeset
159 buffer-file-coding-system))
4650
8905163c49c5 #'find-file: set b-f-c-s even on error (cf. non-existent files),
Aidan Kehoe <kehoea@parhasard.net>
parents: 4647
diff changeset
160 (set-buffer-modified-p nil)
4647
e4ed58cb0e5b Fix bugs with #'find-file, 0-length files, & coding-system-for-read specified.
Aidan Kehoe <kehoea@parhasard.net>
parents: 4623
diff changeset
161 (kill-buffer nil)))
e4ed58cb0e5b Fix bugs with #'find-file, 0-length files, & coding-system-for-read specified.
Aidan Kehoe <kehoea@parhasard.net>
parents: 4623
diff changeset
162 (delete-file existing-file-name))
e4ed58cb0e5b Fix bugs with #'find-file, 0-length files, & coding-system-for-read specified.
Aidan Kehoe <kehoea@parhasard.net>
parents: 4623
diff changeset
163
434
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 428
diff changeset
164 ;;-----------------------------------------------------------------
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 428
diff changeset
165 ;; Test string modification functions that modify the length of a char.
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 428
diff changeset
166 ;;-----------------------------------------------------------------
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 428
diff changeset
167
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 428
diff changeset
168 (when (featurep 'mule)
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
169 ;;---------------------------------------------------------------
434
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 428
diff changeset
170 ;; Test fillarray
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
171 ;;---------------------------------------------------------------
434
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 428
diff changeset
172 (macrolet
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 428
diff changeset
173 ((fillarray-test
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 428
diff changeset
174 (charset1 charset2)
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 428
diff changeset
175 (let ((char1 (make-char charset1 69))
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 428
diff changeset
176 (char2 (make-char charset2 69)))
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 428
diff changeset
177 `(let ((string (make-string 1000 ,char1)))
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 428
diff changeset
178 (fillarray string ,char2)
5136
0f66906b6e37 Undo Assert-equal, Assert=, etc.; make `Assert' handle this automatically
Ben Wing <ben@xemacs.org>
parents: 5107
diff changeset
179 (Assert (eq (aref string 0) ,char2))
0f66906b6e37 Undo Assert-equal, Assert=, etc.; make `Assert' handle this automatically
Ben Wing <ben@xemacs.org>
parents: 5107
diff changeset
180 (Assert (eq (aref string (1- (length string))) ,char2))
0f66906b6e37 Undo Assert-equal, Assert=, etc.; make `Assert' handle this automatically
Ben Wing <ben@xemacs.org>
parents: 5107
diff changeset
181 (Assert (eq (length string) 1000))))))
434
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 428
diff changeset
182 (fillarray-test ascii latin-iso8859-1)
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 428
diff changeset
183 (fillarray-test ascii latin-iso8859-2)
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 428
diff changeset
184 (fillarray-test latin-iso8859-1 ascii)
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 428
diff changeset
185 (fillarray-test latin-iso8859-2 ascii))
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 428
diff changeset
186
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 428
diff changeset
187 ;; Test aset
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 428
diff changeset
188 (let ((string (string (make-char 'ascii 69) (make-char 'latin-iso8859-2 69))))
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 428
diff changeset
189 (aset string 0 (make-char 'latin-iso8859-2 42))
5136
0f66906b6e37 Undo Assert-equal, Assert=, etc.; make `Assert' handle this automatically
Ben Wing <ben@xemacs.org>
parents: 5107
diff changeset
190 (Assert (eq (aref string 1) (make-char 'latin-iso8859-2 69))))
434
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 428
diff changeset
191
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
192 ;;---------------------------------------------------------------
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 438
diff changeset
193 ;; Test coding system functions
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
194 ;;---------------------------------------------------------------
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 438
diff changeset
195
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 438
diff changeset
196 ;; Create alias for coding system without subsidiaries
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 438
diff changeset
197 (Assert (coding-system-p (find-coding-system 'binary)))
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 438
diff changeset
198 (Assert (coding-system-canonical-name-p 'binary))
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 438
diff changeset
199 (Assert (not (coding-system-alias-p 'binary)))
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 438
diff changeset
200 (Assert (not (coding-system-alias-p 'mule-tests-alias)))
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 438
diff changeset
201 (Assert (not (coding-system-canonical-name-p 'mule-tests-alias)))
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 438
diff changeset
202 (Check-Error-Message
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 438
diff changeset
203 error "Symbol is the canonical name of a coding system and cannot be redefined"
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 438
diff changeset
204 (define-coding-system-alias 'binary 'iso8859-2))
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 438
diff changeset
205 (Check-Error-Message
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 438
diff changeset
206 error "Symbol is not a coding system alias"
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 438
diff changeset
207 (coding-system-aliasee 'binary))
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 438
diff changeset
208
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 438
diff changeset
209 (define-coding-system-alias 'mule-tests-alias 'binary)
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 438
diff changeset
210 (Assert (coding-system-alias-p 'mule-tests-alias))
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 438
diff changeset
211 (Assert (not (coding-system-canonical-name-p 'mule-tests-alias)))
5136
0f66906b6e37 Undo Assert-equal, Assert=, etc.; make `Assert' handle this automatically
Ben Wing <ben@xemacs.org>
parents: 5107
diff changeset
212 (Assert (eq (get-coding-system 'binary) (get-coding-system 'mule-tests-alias)))
0f66906b6e37 Undo Assert-equal, Assert=, etc.; make `Assert' handle this automatically
Ben Wing <ben@xemacs.org>
parents: 5107
diff changeset
213 (Assert (eq 'binary (coding-system-aliasee 'mule-tests-alias)))
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 438
diff changeset
214 (Assert (not (coding-system-alias-p 'mule-tests-alias-unix)))
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 438
diff changeset
215 (Assert (not (coding-system-alias-p 'mule-tests-alias-dos)))
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 438
diff changeset
216 (Assert (not (coding-system-alias-p 'mule-tests-alias-mac)))
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 438
diff changeset
217
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 438
diff changeset
218 (define-coding-system-alias 'mule-tests-alias (get-coding-system 'binary))
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 438
diff changeset
219 (Assert (coding-system-alias-p 'mule-tests-alias))
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 438
diff changeset
220 (Assert (not (coding-system-canonical-name-p 'mule-tests-alias)))
5136
0f66906b6e37 Undo Assert-equal, Assert=, etc.; make `Assert' handle this automatically
Ben Wing <ben@xemacs.org>
parents: 5107
diff changeset
221 (Assert (eq (get-coding-system 'binary) (get-coding-system 'mule-tests-alias)))
0f66906b6e37 Undo Assert-equal, Assert=, etc.; make `Assert' handle this automatically
Ben Wing <ben@xemacs.org>
parents: 5107
diff changeset
222 (Assert (eq 'binary (coding-system-aliasee 'mule-tests-alias)))
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 438
diff changeset
223 (Assert (not (coding-system-alias-p 'mule-tests-alias-unix)))
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 438
diff changeset
224 (Assert (not (coding-system-alias-p 'mule-tests-alias-dos)))
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 438
diff changeset
225 (Assert (not (coding-system-alias-p 'mule-tests-alias-mac)))
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 438
diff changeset
226
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 438
diff changeset
227 (define-coding-system-alias 'nested-mule-tests-alias 'mule-tests-alias)
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 438
diff changeset
228 (Assert (coding-system-alias-p 'nested-mule-tests-alias))
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 438
diff changeset
229 (Assert (not (coding-system-canonical-name-p 'nested-mule-tests-alias)))
5136
0f66906b6e37 Undo Assert-equal, Assert=, etc.; make `Assert' handle this automatically
Ben Wing <ben@xemacs.org>
parents: 5107
diff changeset
230 (Assert (eq (get-coding-system 'binary) (get-coding-system 'nested-mule-tests-alias)))
0f66906b6e37 Undo Assert-equal, Assert=, etc.; make `Assert' handle this automatically
Ben Wing <ben@xemacs.org>
parents: 5107
diff changeset
231 (Assert (eq (coding-system-aliasee 'nested-mule-tests-alias) 'mule-tests-alias))
0f66906b6e37 Undo Assert-equal, Assert=, etc.; make `Assert' handle this automatically
Ben Wing <ben@xemacs.org>
parents: 5107
diff changeset
232 (Assert (eq 'mule-tests-alias (coding-system-aliasee 'nested-mule-tests-alias)))
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 438
diff changeset
233 (Assert (not (coding-system-alias-p 'nested-mule-tests-alias-unix)))
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 438
diff changeset
234 (Assert (not (coding-system-alias-p 'nested-mule-tests-alias-dos)))
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 438
diff changeset
235 (Assert (not (coding-system-alias-p 'nested-mule-tests-alias-mac)))
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 438
diff changeset
236
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 438
diff changeset
237 (Check-Error-Message
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 438
diff changeset
238 error "Attempt to create a coding system alias loop"
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 438
diff changeset
239 (define-coding-system-alias 'mule-tests-alias 'nested-mule-tests-alias))
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 438
diff changeset
240 (Check-Error-Message
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 438
diff changeset
241 error "No such coding system"
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 438
diff changeset
242 (define-coding-system-alias 'no-such-coding-system 'no-such-coding-system))
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 438
diff changeset
243 (Check-Error-Message
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 438
diff changeset
244 error "Attempt to create a coding system alias loop"
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 438
diff changeset
245 (define-coding-system-alias 'mule-tests-alias 'mule-tests-alias))
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 438
diff changeset
246
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 438
diff changeset
247 (define-coding-system-alias 'nested-mule-tests-alias nil)
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 438
diff changeset
248 (define-coding-system-alias 'mule-tests-alias nil)
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 438
diff changeset
249 (Assert (coding-system-p (find-coding-system 'binary)))
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 438
diff changeset
250 (Assert (coding-system-canonical-name-p 'binary))
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 438
diff changeset
251 (Assert (not (coding-system-alias-p 'binary)))
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 438
diff changeset
252 (Assert (not (coding-system-alias-p 'mule-tests-alias)))
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 438
diff changeset
253 (Assert (not (coding-system-canonical-name-p 'mule-tests-alias)))
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 438
diff changeset
254 (Check-Error-Message
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 438
diff changeset
255 error "Symbol is the canonical name of a coding system and cannot be redefined"
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 438
diff changeset
256 (define-coding-system-alias 'binary 'iso8859-2))
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 438
diff changeset
257 (Check-Error-Message
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 438
diff changeset
258 error "Symbol is not a coding system alias"
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 438
diff changeset
259 (coding-system-aliasee 'binary))
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 438
diff changeset
260
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 438
diff changeset
261 (define-coding-system-alias 'nested-mule-tests-alias nil)
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 438
diff changeset
262 (define-coding-system-alias 'mule-tests-alias nil)
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 438
diff changeset
263
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 438
diff changeset
264 ;; Create alias for coding system with subsidiaries
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 438
diff changeset
265 (define-coding-system-alias 'mule-tests-alias 'iso-8859-7)
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 438
diff changeset
266 (Assert (coding-system-alias-p 'mule-tests-alias))
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 438
diff changeset
267 (Assert (not (coding-system-canonical-name-p 'mule-tests-alias)))
5136
0f66906b6e37 Undo Assert-equal, Assert=, etc.; make `Assert' handle this automatically
Ben Wing <ben@xemacs.org>
parents: 5107
diff changeset
268 (Assert (eq (get-coding-system 'iso-8859-7) (get-coding-system 'mule-tests-alias)))
0f66906b6e37 Undo Assert-equal, Assert=, etc.; make `Assert' handle this automatically
Ben Wing <ben@xemacs.org>
parents: 5107
diff changeset
269 (Assert (eq 'iso-8859-7 (coding-system-aliasee 'mule-tests-alias)))
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 438
diff changeset
270 (Assert (coding-system-alias-p 'mule-tests-alias-unix))
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 438
diff changeset
271 (Assert (coding-system-alias-p 'mule-tests-alias-dos))
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 438
diff changeset
272 (Assert (coding-system-alias-p 'mule-tests-alias-mac))
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 438
diff changeset
273
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 438
diff changeset
274 (define-coding-system-alias 'mule-tests-alias (get-coding-system 'iso-8859-7))
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 438
diff changeset
275 (Assert (coding-system-alias-p 'mule-tests-alias))
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 438
diff changeset
276 (Assert (not (coding-system-canonical-name-p 'mule-tests-alias)))
5136
0f66906b6e37 Undo Assert-equal, Assert=, etc.; make `Assert' handle this automatically
Ben Wing <ben@xemacs.org>
parents: 5107
diff changeset
277 (Assert (eq (get-coding-system 'iso-8859-7) (get-coding-system 'mule-tests-alias)))
0f66906b6e37 Undo Assert-equal, Assert=, etc.; make `Assert' handle this automatically
Ben Wing <ben@xemacs.org>
parents: 5107
diff changeset
278 (Assert (eq 'iso-8859-7 (coding-system-aliasee 'mule-tests-alias)))
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 438
diff changeset
279 (Assert (coding-system-alias-p 'mule-tests-alias-unix))
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 438
diff changeset
280 (Assert (coding-system-alias-p 'mule-tests-alias-dos))
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 438
diff changeset
281 (Assert (coding-system-alias-p 'mule-tests-alias-mac))
5136
0f66906b6e37 Undo Assert-equal, Assert=, etc.; make `Assert' handle this automatically
Ben Wing <ben@xemacs.org>
parents: 5107
diff changeset
282 (Assert (eq (find-coding-system 'mule-tests-alias-mac)
0f66906b6e37 Undo Assert-equal, Assert=, etc.; make `Assert' handle this automatically
Ben Wing <ben@xemacs.org>
parents: 5107
diff changeset
283 (find-coding-system 'iso-8859-7-mac)))
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 438
diff changeset
284
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 438
diff changeset
285 (define-coding-system-alias 'nested-mule-tests-alias 'mule-tests-alias)
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 438
diff changeset
286 (Assert (coding-system-alias-p 'nested-mule-tests-alias))
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 438
diff changeset
287 (Assert (not (coding-system-canonical-name-p 'nested-mule-tests-alias)))
5136
0f66906b6e37 Undo Assert-equal, Assert=, etc.; make `Assert' handle this automatically
Ben Wing <ben@xemacs.org>
parents: 5107
diff changeset
288 (Assert (eq (get-coding-system 'iso-8859-7)
0f66906b6e37 Undo Assert-equal, Assert=, etc.; make `Assert' handle this automatically
Ben Wing <ben@xemacs.org>
parents: 5107
diff changeset
289 (get-coding-system 'nested-mule-tests-alias)))
0f66906b6e37 Undo Assert-equal, Assert=, etc.; make `Assert' handle this automatically
Ben Wing <ben@xemacs.org>
parents: 5107
diff changeset
290 (Assert (eq (coding-system-aliasee 'nested-mule-tests-alias) 'mule-tests-alias))
0f66906b6e37 Undo Assert-equal, Assert=, etc.; make `Assert' handle this automatically
Ben Wing <ben@xemacs.org>
parents: 5107
diff changeset
291 (Assert (eq 'mule-tests-alias (coding-system-aliasee 'nested-mule-tests-alias)))
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 438
diff changeset
292 (Assert (coding-system-alias-p 'nested-mule-tests-alias-unix))
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 438
diff changeset
293 (Assert (coding-system-alias-p 'nested-mule-tests-alias-dos))
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 438
diff changeset
294 (Assert (coding-system-alias-p 'nested-mule-tests-alias-mac))
5136
0f66906b6e37 Undo Assert-equal, Assert=, etc.; make `Assert' handle this automatically
Ben Wing <ben@xemacs.org>
parents: 5107
diff changeset
295 (Assert (eq (find-coding-system 'nested-mule-tests-alias-unix)
0f66906b6e37 Undo Assert-equal, Assert=, etc.; make `Assert' handle this automatically
Ben Wing <ben@xemacs.org>
parents: 5107
diff changeset
296 (find-coding-system 'iso-8859-7-unix)))
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 438
diff changeset
297
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 438
diff changeset
298 (Check-Error-Message
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 438
diff changeset
299 error "Attempt to create a coding system alias loop"
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 438
diff changeset
300 (define-coding-system-alias 'mule-tests-alias 'nested-mule-tests-alias))
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 438
diff changeset
301 (Check-Error-Message
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 438
diff changeset
302 error "No such coding system"
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 438
diff changeset
303 (define-coding-system-alias 'no-such-coding-system 'no-such-coding-system))
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 438
diff changeset
304 (Check-Error-Message
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 438
diff changeset
305 error "Attempt to create a coding system alias loop"
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 438
diff changeset
306 (define-coding-system-alias 'mule-tests-alias 'mule-tests-alias))
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 438
diff changeset
307
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 438
diff changeset
308 ;; Test dangling alias deletion
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 438
diff changeset
309 (define-coding-system-alias 'mule-tests-alias nil)
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 438
diff changeset
310 (Assert (not (coding-system-alias-p 'mule-tests-alias)))
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 438
diff changeset
311 (Assert (not (coding-system-alias-p 'mule-tests-alias-unix)))
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 438
diff changeset
312 (Assert (not (coding-system-alias-p 'nested-mule-tests-alias)))
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 438
diff changeset
313 (Assert (not (coding-system-alias-p 'nested-mule-tests-alias-dos)))
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 438
diff changeset
314
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
315 ;;---------------------------------------------------------------
438
84b14dcb0985 Import from CVS: tag r21-2-27
cvs
parents: 434
diff changeset
316 ;; Test strings waxing and waning across the 8k BIG_STRING limit (see alloc.c)
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
317 ;;---------------------------------------------------------------
438
84b14dcb0985 Import from CVS: tag r21-2-27
cvs
parents: 434
diff changeset
318 (defun charset-char-string (charset)
2026
ca02e61c9829 [xemacs-hg @ 2004-04-19 06:22:32 by stephent]
stephent
parents: 1316
diff changeset
319 (let (lo hi string n (gc-cons-threshold most-positive-fixnum))
438
84b14dcb0985 Import from CVS: tag r21-2-27
cvs
parents: 434
diff changeset
320 (if (= (charset-chars charset) 94)
84b14dcb0985 Import from CVS: tag r21-2-27
cvs
parents: 434
diff changeset
321 (setq lo 33 hi 126)
84b14dcb0985 Import from CVS: tag r21-2-27
cvs
parents: 434
diff changeset
322 (setq lo 32 hi 127))
84b14dcb0985 Import from CVS: tag r21-2-27
cvs
parents: 434
diff changeset
323 (if (= (charset-dimension charset) 1)
84b14dcb0985 Import from CVS: tag r21-2-27
cvs
parents: 434
diff changeset
324 (progn
84b14dcb0985 Import from CVS: tag r21-2-27
cvs
parents: 434
diff changeset
325 (setq string (make-string (1+ (- hi lo)) ??))
84b14dcb0985 Import from CVS: tag r21-2-27
cvs
parents: 434
diff changeset
326 (setq n 0)
84b14dcb0985 Import from CVS: tag r21-2-27
cvs
parents: 434
diff changeset
327 (loop for j from lo to hi do
84b14dcb0985 Import from CVS: tag r21-2-27
cvs
parents: 434
diff changeset
328 (progn
84b14dcb0985 Import from CVS: tag r21-2-27
cvs
parents: 434
diff changeset
329 (aset string n (make-char charset j))
84b14dcb0985 Import from CVS: tag r21-2-27
cvs
parents: 434
diff changeset
330 (incf n)))
2026
ca02e61c9829 [xemacs-hg @ 2004-04-19 06:22:32 by stephent]
stephent
parents: 1316
diff changeset
331 (garbage-collect)
438
84b14dcb0985 Import from CVS: tag r21-2-27
cvs
parents: 434
diff changeset
332 string)
84b14dcb0985 Import from CVS: tag r21-2-27
cvs
parents: 434
diff changeset
333 (progn
84b14dcb0985 Import from CVS: tag r21-2-27
cvs
parents: 434
diff changeset
334 (setq string (make-string (* (1+ (- hi lo)) (1+ (- hi lo))) ??))
84b14dcb0985 Import from CVS: tag r21-2-27
cvs
parents: 434
diff changeset
335 (setq n 0)
84b14dcb0985 Import from CVS: tag r21-2-27
cvs
parents: 434
diff changeset
336 (loop for j from lo to hi do
84b14dcb0985 Import from CVS: tag r21-2-27
cvs
parents: 434
diff changeset
337 (loop for k from lo to hi do
84b14dcb0985 Import from CVS: tag r21-2-27
cvs
parents: 434
diff changeset
338 (progn
84b14dcb0985 Import from CVS: tag r21-2-27
cvs
parents: 434
diff changeset
339 (aset string n (make-char charset j k))
84b14dcb0985 Import from CVS: tag r21-2-27
cvs
parents: 434
diff changeset
340 (incf n))))
2026
ca02e61c9829 [xemacs-hg @ 2004-04-19 06:22:32 by stephent]
stephent
parents: 1316
diff changeset
341 (garbage-collect)
438
84b14dcb0985 Import from CVS: tag r21-2-27
cvs
parents: 434
diff changeset
342 string))))
84b14dcb0985 Import from CVS: tag r21-2-27
cvs
parents: 434
diff changeset
343
84b14dcb0985 Import from CVS: tag r21-2-27
cvs
parents: 434
diff changeset
344 ;; The following two used to crash xemacs!
84b14dcb0985 Import from CVS: tag r21-2-27
cvs
parents: 434
diff changeset
345 (Assert (charset-char-string 'japanese-jisx0208))
84b14dcb0985 Import from CVS: tag r21-2-27
cvs
parents: 434
diff changeset
346 (aset (make-string 9003 ??) 1 (make-char 'latin-iso8859-1 77))
84b14dcb0985 Import from CVS: tag r21-2-27
cvs
parents: 434
diff changeset
347
84b14dcb0985 Import from CVS: tag r21-2-27
cvs
parents: 434
diff changeset
348 (let ((greek-string (charset-char-string 'greek-iso8859-7))
84b14dcb0985 Import from CVS: tag r21-2-27
cvs
parents: 434
diff changeset
349 (string (make-string (* 96 60) ??)))
84b14dcb0985 Import from CVS: tag r21-2-27
cvs
parents: 434
diff changeset
350 (loop for j from 0 below (length string) do
84b14dcb0985 Import from CVS: tag r21-2-27
cvs
parents: 434
diff changeset
351 (aset string j (aref greek-string (mod j 96))))
84b14dcb0985 Import from CVS: tag r21-2-27
cvs
parents: 434
diff changeset
352 (loop for k in '(0 1 58 59) do
5136
0f66906b6e37 Undo Assert-equal, Assert=, etc.; make `Assert' handle this automatically
Ben Wing <ben@xemacs.org>
parents: 5107
diff changeset
353 (Assert (equal (substring string (* 96 k) (* 96 (1+ k))) greek-string))))
438
84b14dcb0985 Import from CVS: tag r21-2-27
cvs
parents: 434
diff changeset
354
84b14dcb0985 Import from CVS: tag r21-2-27
cvs
parents: 434
diff changeset
355 (let ((greek-string (charset-char-string 'greek-iso8859-7))
84b14dcb0985 Import from CVS: tag r21-2-27
cvs
parents: 434
diff changeset
356 (string (make-string (* 96 60) ??)))
84b14dcb0985 Import from CVS: tag r21-2-27
cvs
parents: 434
diff changeset
357 (loop for j from (1- (length string)) downto 0 do
84b14dcb0985 Import from CVS: tag r21-2-27
cvs
parents: 434
diff changeset
358 (aset string j (aref greek-string (mod j 96))))
84b14dcb0985 Import from CVS: tag r21-2-27
cvs
parents: 434
diff changeset
359 (loop for k in '(0 1 58 59) do
5136
0f66906b6e37 Undo Assert-equal, Assert=, etc.; make `Assert' handle this automatically
Ben Wing <ben@xemacs.org>
parents: 5107
diff changeset
360 (Assert (equal (substring string (* 96 k) (* 96 (1+ k))) greek-string))))
438
84b14dcb0985 Import from CVS: tag r21-2-27
cvs
parents: 434
diff changeset
361
84b14dcb0985 Import from CVS: tag r21-2-27
cvs
parents: 434
diff changeset
362 (let ((ascii-string (charset-char-string 'ascii))
84b14dcb0985 Import from CVS: tag r21-2-27
cvs
parents: 434
diff changeset
363 (string (make-string (* 94 60) (make-char 'greek-iso8859-7 57))))
84b14dcb0985 Import from CVS: tag r21-2-27
cvs
parents: 434
diff changeset
364 (loop for j from 0 below (length string) do
84b14dcb0985 Import from CVS: tag r21-2-27
cvs
parents: 434
diff changeset
365 (aset string j (aref ascii-string (mod j 94))))
84b14dcb0985 Import from CVS: tag r21-2-27
cvs
parents: 434
diff changeset
366 (loop for k in '(0 1 58 59) do
5136
0f66906b6e37 Undo Assert-equal, Assert=, etc.; make `Assert' handle this automatically
Ben Wing <ben@xemacs.org>
parents: 5107
diff changeset
367 (Assert (equal (substring string (* 94 k) (+ 94 (* 94 k))) ascii-string))))
438
84b14dcb0985 Import from CVS: tag r21-2-27
cvs
parents: 434
diff changeset
368
84b14dcb0985 Import from CVS: tag r21-2-27
cvs
parents: 434
diff changeset
369 (let ((ascii-string (charset-char-string 'ascii))
84b14dcb0985 Import from CVS: tag r21-2-27
cvs
parents: 434
diff changeset
370 (string (make-string (* 94 60) (make-char 'greek-iso8859-7 57))))
84b14dcb0985 Import from CVS: tag r21-2-27
cvs
parents: 434
diff changeset
371 (loop for j from (1- (length string)) downto 0 do
84b14dcb0985 Import from CVS: tag r21-2-27
cvs
parents: 434
diff changeset
372 (aset string j (aref ascii-string (mod j 94))))
84b14dcb0985 Import from CVS: tag r21-2-27
cvs
parents: 434
diff changeset
373 (loop for k in '(0 1 58 59) do
5136
0f66906b6e37 Undo Assert-equal, Assert=, etc.; make `Assert' handle this automatically
Ben Wing <ben@xemacs.org>
parents: 5107
diff changeset
374 (Assert (equal (substring string (* 94 k) (* 94 (1+ k))) ascii-string))))
438
84b14dcb0985 Import from CVS: tag r21-2-27
cvs
parents: 434
diff changeset
375
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
376 ;;---------------------------------------------------------------
5107
ae4ddcdf30c0 Test escape-quoted for the range U+0000 to U+00FF.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4957
diff changeset
377 ;; Test string character conversion
ae4ddcdf30c0 Test escape-quoted for the range U+0000 to U+00FF.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4957
diff changeset
378 ;;---------------------------------------------------------------
ae4ddcdf30c0 Test escape-quoted for the range U+0000 to U+00FF.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4957
diff changeset
379
ae4ddcdf30c0 Test escape-quoted for the range U+0000 to U+00FF.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4957
diff changeset
380 ;; #### This should test all coding systems!
ae4ddcdf30c0 Test escape-quoted for the range U+0000 to U+00FF.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4957
diff changeset
381
ae4ddcdf30c0 Test escape-quoted for the range U+0000 to U+00FF.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4957
diff changeset
382 (let ((all-octets (let ((s (make-string 256 ?\000)))
ae4ddcdf30c0 Test escape-quoted for the range U+0000 to U+00FF.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4957
diff changeset
383 (loop for i from (1- (length s)) downto 0 do
ae4ddcdf30c0 Test escape-quoted for the range U+0000 to U+00FF.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4957
diff changeset
384 (aset s i (int-char i)))
ae4ddcdf30c0 Test escape-quoted for the range U+0000 to U+00FF.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4957
diff changeset
385 s))
ae4ddcdf30c0 Test escape-quoted for the range U+0000 to U+00FF.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4957
diff changeset
386 (escape-quoted-result (let ((schar '(27 155 142 143 14 15))
ae4ddcdf30c0 Test escape-quoted for the range U+0000 to U+00FF.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4957
diff changeset
387 (s (make-string 262 ?\000))
ae4ddcdf30c0 Test escape-quoted for the range U+0000 to U+00FF.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4957
diff changeset
388 (pos 0))
ae4ddcdf30c0 Test escape-quoted for the range U+0000 to U+00FF.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4957
diff changeset
389 (loop for ord from 0 to 255 do
ae4ddcdf30c0 Test escape-quoted for the range U+0000 to U+00FF.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4957
diff changeset
390 (when (member ord schar)
ae4ddcdf30c0 Test escape-quoted for the range U+0000 to U+00FF.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4957
diff changeset
391 (aset s pos ?\033)
ae4ddcdf30c0 Test escape-quoted for the range U+0000 to U+00FF.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4957
diff changeset
392 (incf pos))
ae4ddcdf30c0 Test escape-quoted for the range U+0000 to U+00FF.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4957
diff changeset
393 (aset s pos (int-char ord))
ae4ddcdf30c0 Test escape-quoted for the range U+0000 to U+00FF.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4957
diff changeset
394 (incf pos))
ae4ddcdf30c0 Test escape-quoted for the range U+0000 to U+00FF.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4957
diff changeset
395 s)))
ae4ddcdf30c0 Test escape-quoted for the range U+0000 to U+00FF.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4957
diff changeset
396 (Assert (string= (encode-coding-string all-octets 'escape-quoted)
ae4ddcdf30c0 Test escape-quoted for the range U+0000 to U+00FF.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4957
diff changeset
397 escape-quoted-result)))
ae4ddcdf30c0 Test escape-quoted for the range U+0000 to U+00FF.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4957
diff changeset
398
ae4ddcdf30c0 Test escape-quoted for the range U+0000 to U+00FF.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4957
diff changeset
399 ;;---------------------------------------------------------------
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
400 ;; Test file-system character conversion (and, en passant, file ops)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
401 ;;---------------------------------------------------------------
3970
949ac151a10d [xemacs-hg @ 2007-05-20 20:09:20 by aidan]
aidan
parents: 3952
diff changeset
402 (let* ((dstroke (make-char 'latin-iso8859-2 80))
949ac151a10d [xemacs-hg @ 2007-05-20 20:09:20 by aidan]
aidan
parents: 3952
diff changeset
403 (latin2-string (make-string 4 dstroke))
597
ce085c4b3999 [xemacs-hg @ 2001-06-01 05:05:54 by martinb]
martinb
parents: 442
diff changeset
404 (prefix (concat (file-name-as-directory
ce085c4b3999 [xemacs-hg @ 2001-06-01 05:05:54 by martinb]
martinb
parents: 442
diff changeset
405 (file-truename (temp-directory)))
ce085c4b3999 [xemacs-hg @ 2001-06-01 05:05:54 by martinb]
martinb
parents: 442
diff changeset
406 latin2-string))
2026
ca02e61c9829 [xemacs-hg @ 2004-04-19 06:22:32 by stephent]
stephent
parents: 1316
diff changeset
407 (file-name-coding-system
ca02e61c9829 [xemacs-hg @ 2004-04-19 06:22:32 by stephent]
stephent
parents: 1316
diff changeset
408 ;; 'iso-8859-X doesn't work on darwin (as of "Panther" 10.3), it
ca02e61c9829 [xemacs-hg @ 2004-04-19 06:22:32 by stephent]
stephent
parents: 1316
diff changeset
409 ;; seems to know that file-name-coding-system is definitely utf-8
4834
b3ea9c582280 Use new cygwin_conv_path API with Cygwin 1.7 for converting names between Win32 and POSIX, UTF-8-aware, with attendant changes elsewhere
Ben Wing <ben@xemacs.org>
parents: 4731
diff changeset
410 (if (or (string-match "darwin" system-configuration)
b3ea9c582280 Use new cygwin_conv_path API with Cygwin 1.7 for converting names between Win32 and POSIX, UTF-8-aware, with attendant changes elsewhere
Ben Wing <ben@xemacs.org>
parents: 4731
diff changeset
411 (featurep 'cygwin-use-utf-8))
2026
ca02e61c9829 [xemacs-hg @ 2004-04-19 06:22:32 by stephent]
stephent
parents: 1316
diff changeset
412 'utf-8
ca02e61c9829 [xemacs-hg @ 2004-04-19 06:22:32 by stephent]
stephent
parents: 1316
diff changeset
413 'iso-8859-2))
3970
949ac151a10d [xemacs-hg @ 2007-05-20 20:09:20 by aidan]
aidan
parents: 3952
diff changeset
414 ;; make-temp-name does stat(), which on OS X requires that you
949ac151a10d [xemacs-hg @ 2007-05-20 20:09:20 by aidan]
aidan
parents: 3952
diff changeset
415 ;; normalise, where open() will normalise for you. Previously we
949ac151a10d [xemacs-hg @ 2007-05-20 20:09:20 by aidan]
aidan
parents: 3952
diff changeset
416 ;; used scaron as the Latin-2 character, and make-temp-name errored
3976
d76663859e32 [xemacs-hg @ 2007-05-21 08:11:37 by aidan]
aidan
parents: 3970
diff changeset
417 ;; on OS X. LATIN CAPITAL LETTER D WITH STROKE does not decompose.
3970
949ac151a10d [xemacs-hg @ 2007-05-20 20:09:20 by aidan]
aidan
parents: 3952
diff changeset
418 (name1 (make-temp-name prefix))
4465
732b87cfabf2 Document Win32 symlink behaviour; adjust tests to take it into a/c.
Aidan Kehoe <kehoea@parhasard.net>
parents: 4399
diff changeset
419 (name2 (make-temp-name prefix))
732b87cfabf2 Document Win32 symlink behaviour; adjust tests to take it into a/c.
Aidan Kehoe <kehoea@parhasard.net>
parents: 4399
diff changeset
420 (name3 (make-temp-name prefix))
732b87cfabf2 Document Win32 symlink behaviour; adjust tests to take it into a/c.
Aidan Kehoe <kehoea@parhasard.net>
parents: 4399
diff changeset
421 working-symlinks)
3472
43b4a54fbf66 [xemacs-hg @ 2006-06-24 14:30:36 by stephent]
stephent
parents: 3439
diff changeset
422 (Assert (not (equal name1 name2)))
43b4a54fbf66 [xemacs-hg @ 2006-06-24 14:30:36 by stephent]
stephent
parents: 3439
diff changeset
423 (Assert (not (file-exists-p name1)))
4465
732b87cfabf2 Document Win32 symlink behaviour; adjust tests to take it into a/c.
Aidan Kehoe <kehoea@parhasard.net>
parents: 4399
diff changeset
424 ;; This is how you suppress output from `message', called by `write-region'
3472
43b4a54fbf66 [xemacs-hg @ 2006-06-24 14:30:36 by stephent]
stephent
parents: 3439
diff changeset
425 (Silence-Message
43b4a54fbf66 [xemacs-hg @ 2006-06-24 14:30:36 by stephent]
stephent
parents: 3439
diff changeset
426 (write-region (point-min) (point-max) name1))
43b4a54fbf66 [xemacs-hg @ 2006-06-24 14:30:36 by stephent]
stephent
parents: 3439
diff changeset
427 (Assert (file-exists-p name1))
4465
732b87cfabf2 Document Win32 symlink behaviour; adjust tests to take it into a/c.
Aidan Kehoe <kehoea@parhasard.net>
parents: 4399
diff changeset
428 (Silence-Message
732b87cfabf2 Document Win32 symlink behaviour; adjust tests to take it into a/c.
Aidan Kehoe <kehoea@parhasard.net>
parents: 4399
diff changeset
429 (write-region (point-min) (point-max) name3))
732b87cfabf2 Document Win32 symlink behaviour; adjust tests to take it into a/c.
Aidan Kehoe <kehoea@parhasard.net>
parents: 4399
diff changeset
430 (Assert (file-exists-p name3))
732b87cfabf2 Document Win32 symlink behaviour; adjust tests to take it into a/c.
Aidan Kehoe <kehoea@parhasard.net>
parents: 4399
diff changeset
431 (condition-case nil
732b87cfabf2 Document Win32 symlink behaviour; adjust tests to take it into a/c.
Aidan Kehoe <kehoea@parhasard.net>
parents: 4399
diff changeset
432 (make-symbolic-link name1 name3)
732b87cfabf2 Document Win32 symlink behaviour; adjust tests to take it into a/c.
Aidan Kehoe <kehoea@parhasard.net>
parents: 4399
diff changeset
433 (file-already-exists
732b87cfabf2 Document Win32 symlink behaviour; adjust tests to take it into a/c.
Aidan Kehoe <kehoea@parhasard.net>
parents: 4399
diff changeset
434 ;; If we actually have functioning symlinks, we end up here, since
732b87cfabf2 Document Win32 symlink behaviour; adjust tests to take it into a/c.
Aidan Kehoe <kehoea@parhasard.net>
parents: 4399
diff changeset
435 ;; name3 already exists and OK-IF-ALREADY-EXISTS was not specified.
732b87cfabf2 Document Win32 symlink behaviour; adjust tests to take it into a/c.
Aidan Kehoe <kehoea@parhasard.net>
parents: 4399
diff changeset
436 (setq working-symlinks t)))
732b87cfabf2 Document Win32 symlink behaviour; adjust tests to take it into a/c.
Aidan Kehoe <kehoea@parhasard.net>
parents: 4399
diff changeset
437 (when working-symlinks
3472
43b4a54fbf66 [xemacs-hg @ 2006-06-24 14:30:36 by stephent]
stephent
parents: 3439
diff changeset
438 (make-symbolic-link name1 name2)
43b4a54fbf66 [xemacs-hg @ 2006-06-24 14:30:36 by stephent]
stephent
parents: 3439
diff changeset
439 (Assert (file-exists-p name2))
5136
0f66906b6e37 Undo Assert-equal, Assert=, etc.; make `Assert' handle this automatically
Ben Wing <ben@xemacs.org>
parents: 5107
diff changeset
440 (Assert (equal (file-truename name2) name1))
0f66906b6e37 Undo Assert-equal, Assert=, etc.; make `Assert' handle this automatically
Ben Wing <ben@xemacs.org>
parents: 5107
diff changeset
441 (Assert (equal (file-truename name1) name1)))
4465
732b87cfabf2 Document Win32 symlink behaviour; adjust tests to take it into a/c.
Aidan Kehoe <kehoea@parhasard.net>
parents: 4399
diff changeset
442 (ignore-file-errors (delete-file name1))
732b87cfabf2 Document Win32 symlink behaviour; adjust tests to take it into a/c.
Aidan Kehoe <kehoea@parhasard.net>
parents: 4399
diff changeset
443 (ignore-file-errors (delete-file name2))
732b87cfabf2 Document Win32 symlink behaviour; adjust tests to take it into a/c.
Aidan Kehoe <kehoea@parhasard.net>
parents: 4399
diff changeset
444 (ignore-file-errors (delete-file name3)))
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
445
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
446 ;; Add many more file operation tests here...
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
447
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
448 ;;---------------------------------------------------------------
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
449 ;; Test Unicode-related functions
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
450 ;;---------------------------------------------------------------
4861
1f3ed6288996 get make check working again
Ben Wing <ben@xemacs.org>
parents: 4855
diff changeset
451 (let* ((scaron (make-char 'latin-iso8859-2 57)))
875
708faa3b4cb1 [xemacs-hg @ 2002-06-23 06:53:46 by stephent]
stephent
parents: 800
diff changeset
452 ;; Used to try #x0000, but you can't change ASCII or Latin-1
4715
a357478dd457 Fix some test failures, mule-tests.el.
Aidan Kehoe <kehoea@parhasard.net>
parents: 4690
diff changeset
453 (loop
a357478dd457 Fix some test failures, mule-tests.el.
Aidan Kehoe <kehoea@parhasard.net>
parents: 4690
diff changeset
454 for code in '(#x0100 #x2222 #x4444 #xffff)
4861
1f3ed6288996 get make check working again
Ben Wing <ben@xemacs.org>
parents: 4855
diff changeset
455 with initial-unicode = (char-to-unicode scaron)
4715
a357478dd457 Fix some test failures, mule-tests.el.
Aidan Kehoe <kehoea@parhasard.net>
parents: 4690
diff changeset
456 do
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
457 (progn
4861
1f3ed6288996 get make check working again
Ben Wing <ben@xemacs.org>
parents: 4855
diff changeset
458 (set-unicode-conversion scaron code)
5136
0f66906b6e37 Undo Assert-equal, Assert=, etc.; make `Assert' handle this automatically
Ben Wing <ben@xemacs.org>
parents: 5107
diff changeset
459 (Assert (eq code (char-to-unicode scaron)))
0f66906b6e37 Undo Assert-equal, Assert=, etc.; make `Assert' handle this automatically
Ben Wing <ben@xemacs.org>
parents: 5107
diff changeset
460 (Assert (eq scaron (unicode-to-char code '(latin-iso8859-2)))))
4861
1f3ed6288996 get make check working again
Ben Wing <ben@xemacs.org>
parents: 4855
diff changeset
461 finally (set-unicode-conversion scaron initial-unicode))
5307
c096d8051f89 Have NATNUMP give t for positive bignums; check limits appropriately.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5136
diff changeset
462 (Check-Error args-out-of-range (set-unicode-conversion scaron -10000)))
1195
dff007bd492b [xemacs-hg @ 2003-01-09 12:49:36 by stephent]
stephent
parents: 875
diff changeset
463
3439
d1754e7f0cea [xemacs-hg @ 2006-06-03 17:50:39 by aidan]
aidan
parents: 2026
diff changeset
464 (dolist (utf-8-char
d1754e7f0cea [xemacs-hg @ 2006-06-03 17:50:39 by aidan]
aidan
parents: 2026
diff changeset
465 '("\xc6\x92" ;; U+0192 LATIN SMALL LETTER F WITH HOOK
d1754e7f0cea [xemacs-hg @ 2006-06-03 17:50:39 by aidan]
aidan
parents: 2026
diff changeset
466 "\xe2\x81\x8a" ;; U+204A TIRONIAN SIGN ET
d1754e7f0cea [xemacs-hg @ 2006-06-03 17:50:39 by aidan]
aidan
parents: 2026
diff changeset
467 "\xe2\x82\xae" ;; U+20AE TUGRIK SIGN
d1754e7f0cea [xemacs-hg @ 2006-06-03 17:50:39 by aidan]
aidan
parents: 2026
diff changeset
468 "\xf0\x9d\x92\xbd" ;; U+1D4BD MATHEMATICAL SCRIPT SMALL H
d1754e7f0cea [xemacs-hg @ 2006-06-03 17:50:39 by aidan]
aidan
parents: 2026
diff changeset
469 "\xf0\x9d\x96\x93" ;; U+1D593 MATHEMATICAL BOLD FRAKTUR SMALL N
d1754e7f0cea [xemacs-hg @ 2006-06-03 17:50:39 by aidan]
aidan
parents: 2026
diff changeset
470 "\xf0\xaf\xa8\x88" ;; U+2FA08 CJK COMPATIBILITY FOR U+4BCE
d1754e7f0cea [xemacs-hg @ 2006-06-03 17:50:39 by aidan]
aidan
parents: 2026
diff changeset
471 "\xf4\x8f\xbf\xbd")) ;; U+10FFFD <Plane 16 Private Use, Last>
d1754e7f0cea [xemacs-hg @ 2006-06-03 17:50:39 by aidan]
aidan
parents: 2026
diff changeset
472 (let* ((xemacs-character (car (append
d1754e7f0cea [xemacs-hg @ 2006-06-03 17:50:39 by aidan]
aidan
parents: 2026
diff changeset
473 (decode-coding-string utf-8-char 'utf-8)
d1754e7f0cea [xemacs-hg @ 2006-06-03 17:50:39 by aidan]
aidan
parents: 2026
diff changeset
474 nil)))
5136
0f66906b6e37 Undo Assert-equal, Assert=, etc.; make `Assert' handle this automatically
Ben Wing <ben@xemacs.org>
parents: 5107
diff changeset
475 (xemacs-charset (car (split-char xemacs-character))))
3439
d1754e7f0cea [xemacs-hg @ 2006-06-03 17:50:39 by aidan]
aidan
parents: 2026
diff changeset
476
d1754e7f0cea [xemacs-hg @ 2006-06-03 17:50:39 by aidan]
aidan
parents: 2026
diff changeset
477 ;; Trivial test of the UTF-8 support of the escape-quoted character set.
5136
0f66906b6e37 Undo Assert-equal, Assert=, etc.; make `Assert' handle this automatically
Ben Wing <ben@xemacs.org>
parents: 5107
diff changeset
478 (Assert (equal (decode-coding-string utf-8-char 'utf-8)
3439
d1754e7f0cea [xemacs-hg @ 2006-06-03 17:50:39 by aidan]
aidan
parents: 2026
diff changeset
479 (decode-coding-string (concat "\033%G" utf-8-char)
5136
0f66906b6e37 Undo Assert-equal, Assert=, etc.; make `Assert' handle this automatically
Ben Wing <ben@xemacs.org>
parents: 5107
diff changeset
480 'escape-quoted)))
3439
d1754e7f0cea [xemacs-hg @ 2006-06-03 17:50:39 by aidan]
aidan
parents: 2026
diff changeset
481
d1754e7f0cea [xemacs-hg @ 2006-06-03 17:50:39 by aidan]
aidan
parents: 2026
diff changeset
482 ;; Check that the reverse mapping holds.
5136
0f66906b6e37 Undo Assert-equal, Assert=, etc.; make `Assert' handle this automatically
Ben Wing <ben@xemacs.org>
parents: 5107
diff changeset
483 (Assert (equal (unicode-code-point-to-utf-8-string
3439
d1754e7f0cea [xemacs-hg @ 2006-06-03 17:50:39 by aidan]
aidan
parents: 2026
diff changeset
484 (encode-char xemacs-character 'ucs))
5136
0f66906b6e37 Undo Assert-equal, Assert=, etc.; make `Assert' handle this automatically
Ben Wing <ben@xemacs.org>
parents: 5107
diff changeset
485 utf-8-char))
3439
d1754e7f0cea [xemacs-hg @ 2006-06-03 17:50:39 by aidan]
aidan
parents: 2026
diff changeset
486
d1754e7f0cea [xemacs-hg @ 2006-06-03 17:50:39 by aidan]
aidan
parents: 2026
diff changeset
487 ;; Check that, if this character has been JIT-allocated, it is encoded
d1754e7f0cea [xemacs-hg @ 2006-06-03 17:50:39 by aidan]
aidan
parents: 2026
diff changeset
488 ;; in escape-quoted using the corresponding UTF-8 escape.
d1754e7f0cea [xemacs-hg @ 2006-06-03 17:50:39 by aidan]
aidan
parents: 2026
diff changeset
489 (when (charset-property xemacs-charset 'encode-as-utf-8)
5136
0f66906b6e37 Undo Assert-equal, Assert=, etc.; make `Assert' handle this automatically
Ben Wing <ben@xemacs.org>
parents: 5107
diff changeset
490 (Assert (equal (concat "\033%G" utf-8-char)
0f66906b6e37 Undo Assert-equal, Assert=, etc.; make `Assert' handle this automatically
Ben Wing <ben@xemacs.org>
parents: 5107
diff changeset
491 (encode-coding-string xemacs-character 'escape-quoted)))
0f66906b6e37 Undo Assert-equal, Assert=, etc.; make `Assert' handle this automatically
Ben Wing <ben@xemacs.org>
parents: 5107
diff changeset
492 (Assert (equal (concat "\033%G" utf-8-char)
0f66906b6e37 Undo Assert-equal, Assert=, etc.; make `Assert' handle this automatically
Ben Wing <ben@xemacs.org>
parents: 5107
diff changeset
493 (encode-coding-string xemacs-character 'ctext))))))
3439
d1754e7f0cea [xemacs-hg @ 2006-06-03 17:50:39 by aidan]
aidan
parents: 2026
diff changeset
494
3952
3584cb2c07db [xemacs-hg @ 2007-05-13 11:11:28 by aidan]
aidan
parents: 3948
diff changeset
495 (loop
4583
2669b1b7e33b Correct little-endian UTF-16 surrogate handling.
Aidan Kehoe <kehoea@parhasard.net>
parents: 4495
diff changeset
496 for (code-point utf-16-big-endian utf-16-little-endian)
2669b1b7e33b Correct little-endian UTF-16 surrogate handling.
Aidan Kehoe <kehoea@parhasard.net>
parents: 4495
diff changeset
497 in '((#x10000 "\xd8\x00\xdc\x00" "\x00\xd8\x00\xdc")
2669b1b7e33b Correct little-endian UTF-16 surrogate handling.
Aidan Kehoe <kehoea@parhasard.net>
parents: 4495
diff changeset
498 (#x10FFFD "\xdb\xff\xdf\xfd" "\xff\xdb\xfd\xdf"))
2669b1b7e33b Correct little-endian UTF-16 surrogate handling.
Aidan Kehoe <kehoea@parhasard.net>
parents: 4495
diff changeset
499 do
5136
0f66906b6e37 Undo Assert-equal, Assert=, etc.; make `Assert' handle this automatically
Ben Wing <ben@xemacs.org>
parents: 5107
diff changeset
500 (Assert (equal (encode-coding-string
4583
2669b1b7e33b Correct little-endian UTF-16 surrogate handling.
Aidan Kehoe <kehoea@parhasard.net>
parents: 4495
diff changeset
501 (decode-char 'ucs code-point) 'utf-16)
5136
0f66906b6e37 Undo Assert-equal, Assert=, etc.; make `Assert' handle this automatically
Ben Wing <ben@xemacs.org>
parents: 5107
diff changeset
502 utf-16-big-endian))
0f66906b6e37 Undo Assert-equal, Assert=, etc.; make `Assert' handle this automatically
Ben Wing <ben@xemacs.org>
parents: 5107
diff changeset
503 (Assert (equal (encode-coding-string
4583
2669b1b7e33b Correct little-endian UTF-16 surrogate handling.
Aidan Kehoe <kehoea@parhasard.net>
parents: 4495
diff changeset
504 (decode-char 'ucs code-point) 'utf-16-le)
5136
0f66906b6e37 Undo Assert-equal, Assert=, etc.; make `Assert' handle this automatically
Ben Wing <ben@xemacs.org>
parents: 5107
diff changeset
505 utf-16-little-endian)))
4583
2669b1b7e33b Correct little-endian UTF-16 surrogate handling.
Aidan Kehoe <kehoea@parhasard.net>
parents: 4495
diff changeset
506
3952
3584cb2c07db [xemacs-hg @ 2007-05-13 11:11:28 by aidan]
aidan
parents: 3948
diff changeset
507
1195
dff007bd492b [xemacs-hg @ 2003-01-09 12:49:36 by stephent]
stephent
parents: 875
diff changeset
508 ;;---------------------------------------------------------------
3690
d6a215ad08b8 [xemacs-hg @ 2006-11-20 19:21:47 by aidan]
aidan
parents: 3472
diff changeset
509 ;; Regression test for a couple of CCL-related bugs.
d6a215ad08b8 [xemacs-hg @ 2006-11-20 19:21:47 by aidan]
aidan
parents: 3472
diff changeset
510 ;;---------------------------------------------------------------
d6a215ad08b8 [xemacs-hg @ 2006-11-20 19:21:47 by aidan]
aidan
parents: 3472
diff changeset
511
d6a215ad08b8 [xemacs-hg @ 2006-11-20 19:21:47 by aidan]
aidan
parents: 3472
diff changeset
512 (let ((ccl-vector [0 0 0 0 0 0 0 0 0]))
d6a215ad08b8 [xemacs-hg @ 2006-11-20 19:21:47 by aidan]
aidan
parents: 3472
diff changeset
513 (define-ccl-program ccl-write-two-control-1-chars
d6a215ad08b8 [xemacs-hg @ 2006-11-20 19:21:47 by aidan]
aidan
parents: 3472
diff changeset
514 `(1
d6a215ad08b8 [xemacs-hg @ 2006-11-20 19:21:47 by aidan]
aidan
parents: 3472
diff changeset
515 ((r0 = ,(charset-id 'control-1))
d6a215ad08b8 [xemacs-hg @ 2006-11-20 19:21:47 by aidan]
aidan
parents: 3472
diff changeset
516 (r1 = 0)
d6a215ad08b8 [xemacs-hg @ 2006-11-20 19:21:47 by aidan]
aidan
parents: 3472
diff changeset
517 (write-multibyte-character r0 r1)
d6a215ad08b8 [xemacs-hg @ 2006-11-20 19:21:47 by aidan]
aidan
parents: 3472
diff changeset
518 (r1 = 31)
d6a215ad08b8 [xemacs-hg @ 2006-11-20 19:21:47 by aidan]
aidan
parents: 3472
diff changeset
519 (write-multibyte-character r0 r1)))
d6a215ad08b8 [xemacs-hg @ 2006-11-20 19:21:47 by aidan]
aidan
parents: 3472
diff changeset
520 "CCL program that writes two control-1 multibyte characters.")
d6a215ad08b8 [xemacs-hg @ 2006-11-20 19:21:47 by aidan]
aidan
parents: 3472
diff changeset
521
5136
0f66906b6e37 Undo Assert-equal, Assert=, etc.; make `Assert' handle this automatically
Ben Wing <ben@xemacs.org>
parents: 5107
diff changeset
522 (Assert (equal
3690
d6a215ad08b8 [xemacs-hg @ 2006-11-20 19:21:47 by aidan]
aidan
parents: 3472
diff changeset
523 (ccl-execute-on-string 'ccl-write-two-control-1-chars
d6a215ad08b8 [xemacs-hg @ 2006-11-20 19:21:47 by aidan]
aidan
parents: 3472
diff changeset
524 ccl-vector "")
d6a215ad08b8 [xemacs-hg @ 2006-11-20 19:21:47 by aidan]
aidan
parents: 3472
diff changeset
525 (format "%c%c" (make-char 'control-1 0)
5136
0f66906b6e37 Undo Assert-equal, Assert=, etc.; make `Assert' handle this automatically
Ben Wing <ben@xemacs.org>
parents: 5107
diff changeset
526 (make-char 'control-1 31))))
3690
d6a215ad08b8 [xemacs-hg @ 2006-11-20 19:21:47 by aidan]
aidan
parents: 3472
diff changeset
527
d6a215ad08b8 [xemacs-hg @ 2006-11-20 19:21:47 by aidan]
aidan
parents: 3472
diff changeset
528 (define-ccl-program ccl-unicode-two-control-1-chars
d6a215ad08b8 [xemacs-hg @ 2006-11-20 19:21:47 by aidan]
aidan
parents: 3472
diff changeset
529 `(1
d6a215ad08b8 [xemacs-hg @ 2006-11-20 19:21:47 by aidan]
aidan
parents: 3472
diff changeset
530 ((r0 = ,(charset-id 'control-1))
d6a215ad08b8 [xemacs-hg @ 2006-11-20 19:21:47 by aidan]
aidan
parents: 3472
diff changeset
531 (r1 = 31)
d6a215ad08b8 [xemacs-hg @ 2006-11-20 19:21:47 by aidan]
aidan
parents: 3472
diff changeset
532 (mule-to-unicode r0 r1)
d6a215ad08b8 [xemacs-hg @ 2006-11-20 19:21:47 by aidan]
aidan
parents: 3472
diff changeset
533 (r4 = r0)
d6a215ad08b8 [xemacs-hg @ 2006-11-20 19:21:47 by aidan]
aidan
parents: 3472
diff changeset
534 (r3 = ,(charset-id 'control-1))
d6a215ad08b8 [xemacs-hg @ 2006-11-20 19:21:47 by aidan]
aidan
parents: 3472
diff changeset
535 (r2 = 0)
d6a215ad08b8 [xemacs-hg @ 2006-11-20 19:21:47 by aidan]
aidan
parents: 3472
diff changeset
536 (mule-to-unicode r3 r2)))
d6a215ad08b8 [xemacs-hg @ 2006-11-20 19:21:47 by aidan]
aidan
parents: 3472
diff changeset
537 "CCL program that writes two control-1 UCS code points in r3 and r4")
d6a215ad08b8 [xemacs-hg @ 2006-11-20 19:21:47 by aidan]
aidan
parents: 3472
diff changeset
538
d6a215ad08b8 [xemacs-hg @ 2006-11-20 19:21:47 by aidan]
aidan
parents: 3472
diff changeset
539 ;; Re-initialise the vector, mainly to clear the instruction counter,
d6a215ad08b8 [xemacs-hg @ 2006-11-20 19:21:47 by aidan]
aidan
parents: 3472
diff changeset
540 ;; which is its last element.
d6a215ad08b8 [xemacs-hg @ 2006-11-20 19:21:47 by aidan]
aidan
parents: 3472
diff changeset
541 (setq ccl-vector [0 0 0 0 0 0 0 0 0])
d6a215ad08b8 [xemacs-hg @ 2006-11-20 19:21:47 by aidan]
aidan
parents: 3472
diff changeset
542
d6a215ad08b8 [xemacs-hg @ 2006-11-20 19:21:47 by aidan]
aidan
parents: 3472
diff changeset
543 (ccl-execute-on-string 'ccl-unicode-two-control-1-chars ccl-vector "")
d6a215ad08b8 [xemacs-hg @ 2006-11-20 19:21:47 by aidan]
aidan
parents: 3472
diff changeset
544
d6a215ad08b8 [xemacs-hg @ 2006-11-20 19:21:47 by aidan]
aidan
parents: 3472
diff changeset
545 (Assert (and (eq (aref ccl-vector 3)
d6a215ad08b8 [xemacs-hg @ 2006-11-20 19:21:47 by aidan]
aidan
parents: 3472
diff changeset
546 (encode-char (make-char 'control-1 0) 'ucs))
d6a215ad08b8 [xemacs-hg @ 2006-11-20 19:21:47 by aidan]
aidan
parents: 3472
diff changeset
547 (eq (aref ccl-vector 4)
d6a215ad08b8 [xemacs-hg @ 2006-11-20 19:21:47 by aidan]
aidan
parents: 3472
diff changeset
548 (encode-char (make-char 'control-1 31) 'ucs)))))
d6a215ad08b8 [xemacs-hg @ 2006-11-20 19:21:47 by aidan]
aidan
parents: 3472
diff changeset
549
4295
eded49463f9a [xemacs-hg @ 2007-11-29 13:37:51 by aidan]
aidan
parents: 4133
diff changeset
550
eded49463f9a [xemacs-hg @ 2007-11-29 13:37:51 by aidan]
aidan
parents: 4133
diff changeset
551 ;; Test the 8 bit fixed-width coding systems for round-trip
eded49463f9a [xemacs-hg @ 2007-11-29 13:37:51 by aidan]
aidan
parents: 4133
diff changeset
552 ;; compatibility with themselves.
eded49463f9a [xemacs-hg @ 2007-11-29 13:37:51 by aidan]
aidan
parents: 4133
diff changeset
553 (loop
eded49463f9a [xemacs-hg @ 2007-11-29 13:37:51 by aidan]
aidan
parents: 4133
diff changeset
554 for coding-system in (coding-system-list)
eded49463f9a [xemacs-hg @ 2007-11-29 13:37:51 by aidan]
aidan
parents: 4133
diff changeset
555 with all-possible-octets = (apply #'string
eded49463f9a [xemacs-hg @ 2007-11-29 13:37:51 by aidan]
aidan
parents: 4133
diff changeset
556 (loop for i from ?\x00 to ?\xFF
eded49463f9a [xemacs-hg @ 2007-11-29 13:37:51 by aidan]
aidan
parents: 4133
diff changeset
557 collect i))
eded49463f9a [xemacs-hg @ 2007-11-29 13:37:51 by aidan]
aidan
parents: 4133
diff changeset
558 do
4690
257b468bf2ca Move the #'query-coding-region implementation to C.
Aidan Kehoe <kehoea@parhasard.net>
parents: 4688
diff changeset
559 (when (and (eq 'fixed-width (coding-system-type coding-system))
4715
a357478dd457 Fix some test failures, mule-tests.el.
Aidan Kehoe <kehoea@parhasard.net>
parents: 4690
diff changeset
560 ;; Don't check the coding systems with odd line endings
a357478dd457 Fix some test failures, mule-tests.el.
Aidan Kehoe <kehoea@parhasard.net>
parents: 4690
diff changeset
561 ;; (maybe we should):
a357478dd457 Fix some test failures, mule-tests.el.
Aidan Kehoe <kehoea@parhasard.net>
parents: 4690
diff changeset
562 (eq 'lf (coding-system-eol-type coding-system)))
4295
eded49463f9a [xemacs-hg @ 2007-11-29 13:37:51 by aidan]
aidan
parents: 4133
diff changeset
563 ;; These coding systems are round-trip compatible with themselves.
5136
0f66906b6e37 Undo Assert-equal, Assert=, etc.; make `Assert' handle this automatically
Ben Wing <ben@xemacs.org>
parents: 5107
diff changeset
564 (Assert (equal (encode-coding-string
4295
eded49463f9a [xemacs-hg @ 2007-11-29 13:37:51 by aidan]
aidan
parents: 4133
diff changeset
565 (decode-coding-string all-possible-octets
eded49463f9a [xemacs-hg @ 2007-11-29 13:37:51 by aidan]
aidan
parents: 4133
diff changeset
566 coding-system)
eded49463f9a [xemacs-hg @ 2007-11-29 13:37:51 by aidan]
aidan
parents: 4133
diff changeset
567 coding-system)
5136
0f66906b6e37 Undo Assert-equal, Assert=, etc.; make `Assert' handle this automatically
Ben Wing <ben@xemacs.org>
parents: 5107
diff changeset
568 all-possible-octets)
4715
a357478dd457 Fix some test failures, mule-tests.el.
Aidan Kehoe <kehoea@parhasard.net>
parents: 4690
diff changeset
569 (format "checking %s is transparent" coding-system))))
4295
eded49463f9a [xemacs-hg @ 2007-11-29 13:37:51 by aidan]
aidan
parents: 4133
diff changeset
570
3690
d6a215ad08b8 [xemacs-hg @ 2006-11-20 19:21:47 by aidan]
aidan
parents: 3472
diff changeset
571 ;;---------------------------------------------------------------
1195
dff007bd492b [xemacs-hg @ 2003-01-09 12:49:36 by stephent]
stephent
parents: 875
diff changeset
572 ;; Test charset-in-* functions
dff007bd492b [xemacs-hg @ 2003-01-09 12:49:36 by stephent]
stephent
parents: 875
diff changeset
573 ;;---------------------------------------------------------------
dff007bd492b [xemacs-hg @ 2003-01-09 12:49:36 by stephent]
stephent
parents: 875
diff changeset
574 (with-temp-buffer
4884
29fb3baea939 Fix the bugs necessary to resolve the trivial test failures in mule-tests.el
Aidan Kehoe <kehoea@parhasard.net>
parents: 4861
diff changeset
575 (let ((sorted-charsets-in-HELLO
5530
17bcc2aab111 Update the GPLv3 HELLO to use the ISO-IR-196 escape sequences.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5438
diff changeset
576 '(arabic-iso8859-6 ascii chinese-big5-1 chinese-gb2312
17bcc2aab111 Update the GPLv3 HELLO to use the ISO-IR-196 escape sequences.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5438
diff changeset
577 cyrillic-iso8859-5 ethiopic greek-iso8859-7 hebrew-iso8859-8
17bcc2aab111 Update the GPLv3 HELLO to use the ISO-IR-196 escape sequences.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5438
diff changeset
578 indian-is13194 ipa japanese-jisx0208 japanese-jisx0212
17bcc2aab111 Update the GPLv3 HELLO to use the ISO-IR-196 escape sequences.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5438
diff changeset
579 katakana-jisx0201 korean-ksc5601 lao latin-iso8859-1
17bcc2aab111 Update the GPLv3 HELLO to use the ISO-IR-196 escape sequences.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5438
diff changeset
580 latin-iso8859-2 latin-iso8859-3 latin-iso8859-4 thai-tis620
17bcc2aab111 Update the GPLv3 HELLO to use the ISO-IR-196 escape sequences.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5438
diff changeset
581 tibetan vietnamese-viscii-lower))
17bcc2aab111 Update the GPLv3 HELLO to use the ISO-IR-196 escape sequences.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5438
diff changeset
582 (coding-system-for-read 'iso-2022-7))
17bcc2aab111 Update the GPLv3 HELLO to use the ISO-IR-196 escape sequences.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5438
diff changeset
583 (insert-file-contents (locate-data-file "HELLO"))
5136
0f66906b6e37 Undo Assert-equal, Assert=, etc.; make `Assert' handle this automatically
Ben Wing <ben@xemacs.org>
parents: 5107
diff changeset
584 (Assert (equal
4884
29fb3baea939 Fix the bugs necessary to resolve the trivial test failures in mule-tests.el
Aidan Kehoe <kehoea@parhasard.net>
parents: 4861
diff changeset
585 ;; The sort is to make the algorithm of charsets-in-region
29fb3baea939 Fix the bugs necessary to resolve the trivial test failures in mule-tests.el
Aidan Kehoe <kehoea@parhasard.net>
parents: 4861
diff changeset
586 ;; irrelevant.
5530
17bcc2aab111 Update the GPLv3 HELLO to use the ISO-IR-196 escape sequences.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5438
diff changeset
587 (sort (remove* "^jit-ucs-charset-" (charsets-in-region (point-min)
17bcc2aab111 Update the GPLv3 HELLO to use the ISO-IR-196 escape sequences.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5438
diff changeset
588 (point-max))
17bcc2aab111 Update the GPLv3 HELLO to use the ISO-IR-196 escape sequences.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5438
diff changeset
589 :test 'string-match :key 'symbol-name)
4884
29fb3baea939 Fix the bugs necessary to resolve the trivial test failures in mule-tests.el
Aidan Kehoe <kehoea@parhasard.net>
parents: 4861
diff changeset
590 #'string<)
5136
0f66906b6e37 Undo Assert-equal, Assert=, etc.; make `Assert' handle this automatically
Ben Wing <ben@xemacs.org>
parents: 5107
diff changeset
591 sorted-charsets-in-HELLO))
0f66906b6e37 Undo Assert-equal, Assert=, etc.; make `Assert' handle this automatically
Ben Wing <ben@xemacs.org>
parents: 5107
diff changeset
592 (Assert (equal
5530
17bcc2aab111 Update the GPLv3 HELLO to use the ISO-IR-196 escape sequences.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5438
diff changeset
593 (sort (remove* "^jit-ucs-charset-" (charsets-in-string
17bcc2aab111 Update the GPLv3 HELLO to use the ISO-IR-196 escape sequences.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5438
diff changeset
594 (buffer-substring (point-min)
17bcc2aab111 Update the GPLv3 HELLO to use the ISO-IR-196 escape sequences.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5438
diff changeset
595 (point-max)))
17bcc2aab111 Update the GPLv3 HELLO to use the ISO-IR-196 escape sequences.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5438
diff changeset
596 :test 'string-match :key 'symbol-name)
4884
29fb3baea939 Fix the bugs necessary to resolve the trivial test failures in mule-tests.el
Aidan Kehoe <kehoea@parhasard.net>
parents: 4861
diff changeset
597 #'string<)
5136
0f66906b6e37 Undo Assert-equal, Assert=, etc.; make `Assert' handle this automatically
Ben Wing <ben@xemacs.org>
parents: 5107
diff changeset
598 sorted-charsets-in-HELLO))))
3948
adecfd791c9b [xemacs-hg @ 2007-05-12 10:17:00 by aidan]
aidan
parents: 3927
diff changeset
599
4133
5b55fa103aa1 [xemacs-hg @ 2007-08-21 12:38:57 by aidan]
aidan
parents: 4026
diff changeset
600 ;;---------------------------------------------------------------
5b55fa103aa1 [xemacs-hg @ 2007-08-21 12:38:57 by aidan]
aidan
parents: 4026
diff changeset
601 ;; Language environments, and whether the specified values are sane.
5b55fa103aa1 [xemacs-hg @ 2007-08-21 12:38:57 by aidan]
aidan
parents: 4026
diff changeset
602 ;;---------------------------------------------------------------
5b55fa103aa1 [xemacs-hg @ 2007-08-21 12:38:57 by aidan]
aidan
parents: 4026
diff changeset
603 (loop
5b55fa103aa1 [xemacs-hg @ 2007-08-21 12:38:57 by aidan]
aidan
parents: 4026
diff changeset
604 for language in (mapcar #'car language-info-alist)
5b55fa103aa1 [xemacs-hg @ 2007-08-21 12:38:57 by aidan]
aidan
parents: 4026
diff changeset
605 with language-input-method = nil
4305
2bb3630ea397 [xemacs-hg @ 2007-12-04 20:40:49 by aidan]
aidan
parents: 4295
diff changeset
606 with native-coding-system = nil
4672
938ffa3ffe4d Revert to original language environment, tests/automated/mule-tests.el.
Aidan Kehoe <kehoea@parhasard.net>
parents: 4650
diff changeset
607 with original-language-environment = current-language-environment
4133
5b55fa103aa1 [xemacs-hg @ 2007-08-21 12:38:57 by aidan]
aidan
parents: 4026
diff changeset
608 do
5b55fa103aa1 [xemacs-hg @ 2007-08-21 12:38:57 by aidan]
aidan
parents: 4026
diff changeset
609 ;; s-l-e can call #'require, which says "Loading ..."
5b55fa103aa1 [xemacs-hg @ 2007-08-21 12:38:57 by aidan]
aidan
parents: 4026
diff changeset
610 (Silence-Message (set-language-environment language))
5136
0f66906b6e37 Undo Assert-equal, Assert=, etc.; make `Assert' handle this automatically
Ben Wing <ben@xemacs.org>
parents: 5107
diff changeset
611 (Assert (equal language current-language-environment))
4133
5b55fa103aa1 [xemacs-hg @ 2007-08-21 12:38:57 by aidan]
aidan
parents: 4026
diff changeset
612
5b55fa103aa1 [xemacs-hg @ 2007-08-21 12:38:57 by aidan]
aidan
parents: 4026
diff changeset
613 (setq language-input-method
5b55fa103aa1 [xemacs-hg @ 2007-08-21 12:38:57 by aidan]
aidan
parents: 4026
diff changeset
614 (get-language-info language 'input-method))
5b55fa103aa1 [xemacs-hg @ 2007-08-21 12:38:57 by aidan]
aidan
parents: 4026
diff changeset
615 (when (and language-input-method
5b55fa103aa1 [xemacs-hg @ 2007-08-21 12:38:57 by aidan]
aidan
parents: 4026
diff changeset
616 ;; #### Not robust, if more input methods besides canna are
5b55fa103aa1 [xemacs-hg @ 2007-08-21 12:38:57 by aidan]
aidan
parents: 4026
diff changeset
617 ;; in core. The intention of this is that if *any* of the
5b55fa103aa1 [xemacs-hg @ 2007-08-21 12:38:57 by aidan]
aidan
parents: 4026
diff changeset
618 ;; packages' input methods are available, we check that *all*
5b55fa103aa1 [xemacs-hg @ 2007-08-21 12:38:57 by aidan]
aidan
parents: 4026
diff changeset
619 ;; of the language environments' input methods actually
5b55fa103aa1 [xemacs-hg @ 2007-08-21 12:38:57 by aidan]
aidan
parents: 4026
diff changeset
620 ;; exist, which goes against the spirit of non-monolithic
5b55fa103aa1 [xemacs-hg @ 2007-08-21 12:38:57 by aidan]
aidan
parents: 4026
diff changeset
621 ;; packages. But I don't have a better approach to this.
5b55fa103aa1 [xemacs-hg @ 2007-08-21 12:38:57 by aidan]
aidan
parents: 4026
diff changeset
622 (> (length input-method-alist) 1))
5b55fa103aa1 [xemacs-hg @ 2007-08-21 12:38:57 by aidan]
aidan
parents: 4026
diff changeset
623 (Assert (assoc language-input-method input-method-alist))
5b55fa103aa1 [xemacs-hg @ 2007-08-21 12:38:57 by aidan]
aidan
parents: 4026
diff changeset
624 (Skip-Test-Unless
5b55fa103aa1 [xemacs-hg @ 2007-08-21 12:38:57 by aidan]
aidan
parents: 4026
diff changeset
625 (assoc language-input-method input-method-alist)
5b55fa103aa1 [xemacs-hg @ 2007-08-21 12:38:57 by aidan]
aidan
parents: 4026
diff changeset
626 "input method unavailable"
5b55fa103aa1 [xemacs-hg @ 2007-08-21 12:38:57 by aidan]
aidan
parents: 4026
diff changeset
627 (format "check that IM %s can be activated" language-input-method)
5b55fa103aa1 [xemacs-hg @ 2007-08-21 12:38:57 by aidan]
aidan
parents: 4026
diff changeset
628 ;; s-i-m can load files.
5b55fa103aa1 [xemacs-hg @ 2007-08-21 12:38:57 by aidan]
aidan
parents: 4026
diff changeset
629 (Silence-Message
5b55fa103aa1 [xemacs-hg @ 2007-08-21 12:38:57 by aidan]
aidan
parents: 4026
diff changeset
630 (set-input-method language-input-method))
5136
0f66906b6e37 Undo Assert-equal, Assert=, etc.; make `Assert' handle this automatically
Ben Wing <ben@xemacs.org>
parents: 5107
diff changeset
631 (Assert (equal language-input-method current-input-method))))
4133
5b55fa103aa1 [xemacs-hg @ 2007-08-21 12:38:57 by aidan]
aidan
parents: 4026
diff changeset
632
3970
949ac151a10d [xemacs-hg @ 2007-05-20 20:09:20 by aidan]
aidan
parents: 3952
diff changeset
633 (dolist (charset (get-language-info language 'charset))
949ac151a10d [xemacs-hg @ 2007-05-20 20:09:20 by aidan]
aidan
parents: 3952
diff changeset
634 (Assert (charsetp (find-charset charset))))
949ac151a10d [xemacs-hg @ 2007-05-20 20:09:20 by aidan]
aidan
parents: 3952
diff changeset
635 (dolist (coding-system (get-language-info language 'coding-system))
949ac151a10d [xemacs-hg @ 2007-05-20 20:09:20 by aidan]
aidan
parents: 3952
diff changeset
636 (Assert (coding-system-p (find-coding-system coding-system))))
4305
2bb3630ea397 [xemacs-hg @ 2007-12-04 20:40:49 by aidan]
aidan
parents: 4295
diff changeset
637 (dolist (coding-system
2bb3630ea397 [xemacs-hg @ 2007-12-04 20:40:49 by aidan]
aidan
parents: 4295
diff changeset
638 (if (listp (setq native-coding-system
2bb3630ea397 [xemacs-hg @ 2007-12-04 20:40:49 by aidan]
aidan
parents: 4295
diff changeset
639 (get-language-info language
2bb3630ea397 [xemacs-hg @ 2007-12-04 20:40:49 by aidan]
aidan
parents: 4295
diff changeset
640 'native-coding-system)))
2bb3630ea397 [xemacs-hg @ 2007-12-04 20:40:49 by aidan]
aidan
parents: 4295
diff changeset
641 native-coding-system
2bb3630ea397 [xemacs-hg @ 2007-12-04 20:40:49 by aidan]
aidan
parents: 4295
diff changeset
642 (list native-coding-system)))
4133
5b55fa103aa1 [xemacs-hg @ 2007-08-21 12:38:57 by aidan]
aidan
parents: 4026
diff changeset
643 ;; We don't have the appropriate POSIX locales to test with a
5b55fa103aa1 [xemacs-hg @ 2007-08-21 12:38:57 by aidan]
aidan
parents: 4026
diff changeset
644 ;; native-coding-system that is a function.
5b55fa103aa1 [xemacs-hg @ 2007-08-21 12:38:57 by aidan]
aidan
parents: 4026
diff changeset
645 (unless (functionp coding-system)
4672
938ffa3ffe4d Revert to original language environment, tests/automated/mule-tests.el.
Aidan Kehoe <kehoea@parhasard.net>
parents: 4650
diff changeset
646 (Assert (coding-system-p (find-coding-system coding-system)))))
938ffa3ffe4d Revert to original language environment, tests/automated/mule-tests.el.
Aidan Kehoe <kehoea@parhasard.net>
parents: 4650
diff changeset
647 finally (set-language-environment original-language-environment))
3970
949ac151a10d [xemacs-hg @ 2007-05-20 20:09:20 by aidan]
aidan
parents: 3952
diff changeset
648
3948
adecfd791c9b [xemacs-hg @ 2007-05-12 10:17:00 by aidan]
aidan
parents: 3927
diff changeset
649 (with-temp-buffer
5576
071b810ceb18 Declare labels as line where appropriate; use #'labels, not #'flet, tests.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5530
diff changeset
650 (labels
3948
adecfd791c9b [xemacs-hg @ 2007-05-12 10:17:00 by aidan]
aidan
parents: 3927
diff changeset
651 ((Assert-elc-is-escape-quoted ()
adecfd791c9b [xemacs-hg @ 2007-05-12 10:17:00 by aidan]
aidan
parents: 3927
diff changeset
652 "Assert the current buffer has an escape-quoted cookie if compiled."
adecfd791c9b [xemacs-hg @ 2007-05-12 10:17:00 by aidan]
aidan
parents: 3927
diff changeset
653 (save-excursion
4623
a9f83990e6bf Fix a byte compiler bug with characters above ?\xFF.
Aidan Kehoe <kehoea@parhasard.net>
parents: 4620
diff changeset
654 (let* ((temporary-file-name (make-temp-name
a9f83990e6bf Fix a byte compiler bug with characters above ?\xFF.
Aidan Kehoe <kehoea@parhasard.net>
parents: 4620
diff changeset
655 (expand-file-name "zjPQ2Pk"
a9f83990e6bf Fix a byte compiler bug with characters above ?\xFF.
Aidan Kehoe <kehoea@parhasard.net>
parents: 4620
diff changeset
656 (temp-directory))))
5595
391d809fa4e9 Update tests that have started failing because of changed design decisions.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5576
diff changeset
657 (byte-compile-result
391d809fa4e9 Update tests that have started failing because of changed design decisions.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5576
diff changeset
658 (Silence-Message (byte-compile-from-buffer
391d809fa4e9 Update tests that have started failing because of changed design decisions.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5576
diff changeset
659 (current-buffer) temporary-file-name
391d809fa4e9 Update tests that have started failing because of changed design decisions.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5576
diff changeset
660 nil))))
4133
5b55fa103aa1 [xemacs-hg @ 2007-08-21 12:38:57 by aidan]
aidan
parents: 4026
diff changeset
661 (Assert (string-match
5b55fa103aa1 [xemacs-hg @ 2007-08-21 12:38:57 by aidan]
aidan
parents: 4026
diff changeset
662 "^;;;###coding system: escape-quoted"
5b55fa103aa1 [xemacs-hg @ 2007-08-21 12:38:57 by aidan]
aidan
parents: 4026
diff changeset
663 (buffer-substring nil nil byte-compile-result))))))
5595
391d809fa4e9 Update tests that have started failing because of changed design decisions.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5576
diff changeset
664 (Assert-elc-is-raw-text-unix ()
3948
adecfd791c9b [xemacs-hg @ 2007-05-12 10:17:00 by aidan]
aidan
parents: 3927
diff changeset
665 "Assert the current buffer has no coding cookie if compiled."
adecfd791c9b [xemacs-hg @ 2007-05-12 10:17:00 by aidan]
aidan
parents: 3927
diff changeset
666 (save-excursion
4623
a9f83990e6bf Fix a byte compiler bug with characters above ?\xFF.
Aidan Kehoe <kehoea@parhasard.net>
parents: 4620
diff changeset
667 (let* ((temporary-file-name (make-temp-name
a9f83990e6bf Fix a byte compiler bug with characters above ?\xFF.
Aidan Kehoe <kehoea@parhasard.net>
parents: 4620
diff changeset
668 (expand-file-name "zjPQ2Pk"
a9f83990e6bf Fix a byte compiler bug with characters above ?\xFF.
Aidan Kehoe <kehoea@parhasard.net>
parents: 4620
diff changeset
669 (temp-directory))))
5595
391d809fa4e9 Update tests that have started failing because of changed design decisions.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5576
diff changeset
670 (byte-compile-result
391d809fa4e9 Update tests that have started failing because of changed design decisions.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5576
diff changeset
671 (Silence-Message
391d809fa4e9 Update tests that have started failing because of changed design decisions.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5576
diff changeset
672 (byte-compile-from-buffer (current-buffer)
391d809fa4e9 Update tests that have started failing because of changed design decisions.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5576
diff changeset
673 temporary-file-name nil))))
391d809fa4e9 Update tests that have started failing because of changed design decisions.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5576
diff changeset
674 (Assert (string-match
391d809fa4e9 Update tests that have started failing because of changed design decisions.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5576
diff changeset
675 "^;;;###coding system: raw-text-unix"
391d809fa4e9 Update tests that have started failing because of changed design decisions.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5576
diff changeset
676 (buffer-substring nil nil byte-compile-result)))))))
3948
adecfd791c9b [xemacs-hg @ 2007-05-12 10:17:00 by aidan]
aidan
parents: 3927
diff changeset
677 (insert
4133
5b55fa103aa1 [xemacs-hg @ 2007-08-21 12:38:57 by aidan]
aidan
parents: 4026
diff changeset
678 ;; Create a buffer with Unicode escapes. The #'read call is at
5b55fa103aa1 [xemacs-hg @ 2007-08-21 12:38:57 by aidan]
aidan
parents: 4026
diff changeset
679 ;; runtime, because this file may be compiled and read in a non-Mule
5b55fa103aa1 [xemacs-hg @ 2007-08-21 12:38:57 by aidan]
aidan
parents: 4026
diff changeset
680 ;; XEmacs. (But it won't be run.)
5b55fa103aa1 [xemacs-hg @ 2007-08-21 12:38:57 by aidan]
aidan
parents: 4026
diff changeset
681 (read
5b55fa103aa1 [xemacs-hg @ 2007-08-21 12:38:57 by aidan]
aidan
parents: 4026
diff changeset
682 "#r\" (defvar testing-mule-compilation-handling
5b55fa103aa1 [xemacs-hg @ 2007-08-21 12:38:57 by aidan]
aidan
parents: 4026
diff changeset
683 (string ?\\u371E ;; kDefinition beautiful; pretty, used
3948
adecfd791c9b [xemacs-hg @ 2007-05-12 10:17:00 by aidan]
aidan
parents: 3927
diff changeset
684 ;; in girl's name
4133
5b55fa103aa1 [xemacs-hg @ 2007-08-21 12:38:57 by aidan]
aidan
parents: 4026
diff changeset
685 ?\\U0002A6A9 ;; kDefinition (Cant.) sound of shouting
5b55fa103aa1 [xemacs-hg @ 2007-08-21 12:38:57 by aidan]
aidan
parents: 4026
diff changeset
686 ?\\U0002A65B ;; kDefinition (Cant.) decayed teeth;
3948
adecfd791c9b [xemacs-hg @ 2007-05-12 10:17:00 by aidan]
aidan
parents: 3927
diff changeset
687 ;; tongue-tied
4133
5b55fa103aa1 [xemacs-hg @ 2007-08-21 12:38:57 by aidan]
aidan
parents: 4026
diff changeset
688 ?\\U00010400 ;; DESERET CAPITAL LETTER LONG I
5b55fa103aa1 [xemacs-hg @ 2007-08-21 12:38:57 by aidan]
aidan
parents: 4026
diff changeset
689 ?\\u3263)) ;; CIRCLED HANGUL RIEUL \""))
3948
adecfd791c9b [xemacs-hg @ 2007-05-12 10:17:00 by aidan]
aidan
parents: 3927
diff changeset
690
adecfd791c9b [xemacs-hg @ 2007-05-12 10:17:00 by aidan]
aidan
parents: 3927
diff changeset
691 (Assert-elc-is-escape-quoted)
adecfd791c9b [xemacs-hg @ 2007-05-12 10:17:00 by aidan]
aidan
parents: 3927
diff changeset
692 (delete-region (point-min) (point-max))
adecfd791c9b [xemacs-hg @ 2007-05-12 10:17:00 by aidan]
aidan
parents: 3927
diff changeset
693
adecfd791c9b [xemacs-hg @ 2007-05-12 10:17:00 by aidan]
aidan
parents: 3927
diff changeset
694 (insert
adecfd791c9b [xemacs-hg @ 2007-05-12 10:17:00 by aidan]
aidan
parents: 3927
diff changeset
695 ;; This time, the buffer will contain the actual characters, because of
adecfd791c9b [xemacs-hg @ 2007-05-12 10:17:00 by aidan]
aidan
parents: 3927
diff changeset
696 ;; u flag to the #r.
4133
5b55fa103aa1 [xemacs-hg @ 2007-08-21 12:38:57 by aidan]
aidan
parents: 4026
diff changeset
697 (read
5b55fa103aa1 [xemacs-hg @ 2007-08-21 12:38:57 by aidan]
aidan
parents: 4026
diff changeset
698 "#ru\" (defvar testing-mule-compilation-handling
5b55fa103aa1 [xemacs-hg @ 2007-08-21 12:38:57 by aidan]
aidan
parents: 4026
diff changeset
699 (string ?\\u371E ;; kDefinition beautiful; pretty, used
3948
adecfd791c9b [xemacs-hg @ 2007-05-12 10:17:00 by aidan]
aidan
parents: 3927
diff changeset
700 ;; in girl's name
4133
5b55fa103aa1 [xemacs-hg @ 2007-08-21 12:38:57 by aidan]
aidan
parents: 4026
diff changeset
701 ?\\U0002A6A9 ;; kDefinition (Cant.) sound of shouting
5b55fa103aa1 [xemacs-hg @ 2007-08-21 12:38:57 by aidan]
aidan
parents: 4026
diff changeset
702 ?\\U0002A65B ;; kDefinition (Cant.) decayed teeth;
3948
adecfd791c9b [xemacs-hg @ 2007-05-12 10:17:00 by aidan]
aidan
parents: 3927
diff changeset
703 ;; tongue-tied
4133
5b55fa103aa1 [xemacs-hg @ 2007-08-21 12:38:57 by aidan]
aidan
parents: 4026
diff changeset
704 ?\\U00010400 ;; DESERET CAPITAL LETTER LONG I
5b55fa103aa1 [xemacs-hg @ 2007-08-21 12:38:57 by aidan]
aidan
parents: 4026
diff changeset
705 ?\\u3263)) ;; CIRCLED HANGUL RIEUL \""))
3948
adecfd791c9b [xemacs-hg @ 2007-05-12 10:17:00 by aidan]
aidan
parents: 3927
diff changeset
706
adecfd791c9b [xemacs-hg @ 2007-05-12 10:17:00 by aidan]
aidan
parents: 3927
diff changeset
707 (Assert-elc-is-escape-quoted)
adecfd791c9b [xemacs-hg @ 2007-05-12 10:17:00 by aidan]
aidan
parents: 3927
diff changeset
708 (delete-region (point-min) (point-max))
adecfd791c9b [xemacs-hg @ 2007-05-12 10:17:00 by aidan]
aidan
parents: 3927
diff changeset
709
adecfd791c9b [xemacs-hg @ 2007-05-12 10:17:00 by aidan]
aidan
parents: 3927
diff changeset
710 (insert
adecfd791c9b [xemacs-hg @ 2007-05-12 10:17:00 by aidan]
aidan
parents: 3927
diff changeset
711 ;; Just a single four character escape.
4133
5b55fa103aa1 [xemacs-hg @ 2007-08-21 12:38:57 by aidan]
aidan
parents: 4026
diff changeset
712 (read
5b55fa103aa1 [xemacs-hg @ 2007-08-21 12:38:57 by aidan]
aidan
parents: 4026
diff changeset
713 "#r\" (defvar testing-mule-compilation-handling
5b55fa103aa1 [xemacs-hg @ 2007-08-21 12:38:57 by aidan]
aidan
parents: 4026
diff changeset
714 (string ?\\u371E)) ;; kDefinition beautiful; pretty, used\""))
3948
adecfd791c9b [xemacs-hg @ 2007-05-12 10:17:00 by aidan]
aidan
parents: 3927
diff changeset
715
adecfd791c9b [xemacs-hg @ 2007-05-12 10:17:00 by aidan]
aidan
parents: 3927
diff changeset
716 (Assert-elc-is-escape-quoted)
adecfd791c9b [xemacs-hg @ 2007-05-12 10:17:00 by aidan]
aidan
parents: 3927
diff changeset
717 (delete-region (point-min) (point-max))
adecfd791c9b [xemacs-hg @ 2007-05-12 10:17:00 by aidan]
aidan
parents: 3927
diff changeset
718
adecfd791c9b [xemacs-hg @ 2007-05-12 10:17:00 by aidan]
aidan
parents: 3927
diff changeset
719 (insert
adecfd791c9b [xemacs-hg @ 2007-05-12 10:17:00 by aidan]
aidan
parents: 3927
diff changeset
720 ;; Just a single eight character escape.
4133
5b55fa103aa1 [xemacs-hg @ 2007-08-21 12:38:57 by aidan]
aidan
parents: 4026
diff changeset
721 (read
5b55fa103aa1 [xemacs-hg @ 2007-08-21 12:38:57 by aidan]
aidan
parents: 4026
diff changeset
722 "#r\" (defvar testing-mule-compilation-handling
5b55fa103aa1 [xemacs-hg @ 2007-08-21 12:38:57 by aidan]
aidan
parents: 4026
diff changeset
723 (string ?\\U0002A65B)) ;; kDefinition (Cant.) decayed teeth;\""))
3948
adecfd791c9b [xemacs-hg @ 2007-05-12 10:17:00 by aidan]
aidan
parents: 3927
diff changeset
724
adecfd791c9b [xemacs-hg @ 2007-05-12 10:17:00 by aidan]
aidan
parents: 3927
diff changeset
725 (Assert-elc-is-escape-quoted)
adecfd791c9b [xemacs-hg @ 2007-05-12 10:17:00 by aidan]
aidan
parents: 3927
diff changeset
726 (delete-region (point-min) (point-max))
adecfd791c9b [xemacs-hg @ 2007-05-12 10:17:00 by aidan]
aidan
parents: 3927
diff changeset
727
adecfd791c9b [xemacs-hg @ 2007-05-12 10:17:00 by aidan]
aidan
parents: 3927
diff changeset
728 (insert
4133
5b55fa103aa1 [xemacs-hg @ 2007-08-21 12:38:57 by aidan]
aidan
parents: 4026
diff changeset
729 ;; A single latin-1 hex digit escape No run-time #'read call,
5b55fa103aa1 [xemacs-hg @ 2007-08-21 12:38:57 by aidan]
aidan
parents: 4026
diff changeset
730 ;; non-Mule can handle this too.
3948
adecfd791c9b [xemacs-hg @ 2007-05-12 10:17:00 by aidan]
aidan
parents: 3927
diff changeset
731 #r" (defvar testing-mule-compilation-handling
4133
5b55fa103aa1 [xemacs-hg @ 2007-08-21 12:38:57 by aidan]
aidan
parents: 4026
diff changeset
732 (string ?\xab)) ;; LEFT-POINTING DOUBLE ANGLE QUOTATION MARK")
5b55fa103aa1 [xemacs-hg @ 2007-08-21 12:38:57 by aidan]
aidan
parents: 4026
diff changeset
733
5595
391d809fa4e9 Update tests that have started failing because of changed design decisions.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5576
diff changeset
734 (Assert-elc-is-raw-text-unix)
4133
5b55fa103aa1 [xemacs-hg @ 2007-08-21 12:38:57 by aidan]
aidan
parents: 4026
diff changeset
735 (delete-region (point-min) (point-max))
5b55fa103aa1 [xemacs-hg @ 2007-08-21 12:38:57 by aidan]
aidan
parents: 4026
diff changeset
736
5b55fa103aa1 [xemacs-hg @ 2007-08-21 12:38:57 by aidan]
aidan
parents: 4026
diff changeset
737 (insert
5b55fa103aa1 [xemacs-hg @ 2007-08-21 12:38:57 by aidan]
aidan
parents: 4026
diff changeset
738 ;; A single latin-1 character. No run-time #'read call.
5b55fa103aa1 [xemacs-hg @ 2007-08-21 12:38:57 by aidan]
aidan
parents: 4026
diff changeset
739 #ru" (defvar testing-mule-compilation-handling
5b55fa103aa1 [xemacs-hg @ 2007-08-21 12:38:57 by aidan]
aidan
parents: 4026
diff changeset
740 (string ?\u00AB)) ;; LEFT-POINTING DOUBLE ANGLE QUOTATION MARK\")")
3948
adecfd791c9b [xemacs-hg @ 2007-05-12 10:17:00 by aidan]
aidan
parents: 3927
diff changeset
741
5595
391d809fa4e9 Update tests that have started failing because of changed design decisions.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5576
diff changeset
742 (Assert-elc-is-raw-text-unix)
3948
adecfd791c9b [xemacs-hg @ 2007-05-12 10:17:00 by aidan]
aidan
parents: 3927
diff changeset
743 (delete-region (point-min) (point-max))
adecfd791c9b [xemacs-hg @ 2007-05-12 10:17:00 by aidan]
aidan
parents: 3927
diff changeset
744
adecfd791c9b [xemacs-hg @ 2007-05-12 10:17:00 by aidan]
aidan
parents: 3927
diff changeset
745 (insert
4133
5b55fa103aa1 [xemacs-hg @ 2007-08-21 12:38:57 by aidan]
aidan
parents: 4026
diff changeset
746 ;; Just ASCII. No run-time #'read call
5b55fa103aa1 [xemacs-hg @ 2007-08-21 12:38:57 by aidan]
aidan
parents: 4026
diff changeset
747 #r" (defvar testing-mule-compilation-handling
5b55fa103aa1 [xemacs-hg @ 2007-08-21 12:38:57 by aidan]
aidan
parents: 4026
diff changeset
748 (string ?A)) ;; LATIN CAPITAL LETTER A")
3948
adecfd791c9b [xemacs-hg @ 2007-05-12 10:17:00 by aidan]
aidan
parents: 3927
diff changeset
749
5595
391d809fa4e9 Update tests that have started failing because of changed design decisions.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5576
diff changeset
750 (Assert-elc-is-raw-text-unix)
3948
adecfd791c9b [xemacs-hg @ 2007-05-12 10:17:00 by aidan]
aidan
parents: 3927
diff changeset
751 (delete-region (point-min) (point-max))
adecfd791c9b [xemacs-hg @ 2007-05-12 10:17:00 by aidan]
aidan
parents: 3927
diff changeset
752
4623
a9f83990e6bf Fix a byte compiler bug with characters above ?\xFF.
Aidan Kehoe <kehoea@parhasard.net>
parents: 4620
diff changeset
753 ;; There used to be a bug here because the coding-cookie insertion code
a9f83990e6bf Fix a byte compiler bug with characters above ?\xFF.
Aidan Kehoe <kehoea@parhasard.net>
parents: 4620
diff changeset
754 ;; looks at the input buffer, not the output buffer.
4133
5b55fa103aa1 [xemacs-hg @ 2007-08-21 12:38:57 by aidan]
aidan
parents: 4026
diff changeset
755 ;;
5b55fa103aa1 [xemacs-hg @ 2007-08-21 12:38:57 by aidan]
aidan
parents: 4026
diff changeset
756 ;; It looks at the input buffer because byte-compile-dynamic and
5b55fa103aa1 [xemacs-hg @ 2007-08-21 12:38:57 by aidan]
aidan
parents: 4026
diff changeset
757 ;; byte-compile-dynamic-docstrings currently need to be
5b55fa103aa1 [xemacs-hg @ 2007-08-21 12:38:57 by aidan]
aidan
parents: 4026
diff changeset
758 ;; unconditionally turned off for Mule files, since dynamic
5b55fa103aa1 [xemacs-hg @ 2007-08-21 12:38:57 by aidan]
aidan
parents: 4026
diff changeset
759 ;; compilation of function bodies and docstrings fails if you can't
5b55fa103aa1 [xemacs-hg @ 2007-08-21 12:38:57 by aidan]
aidan
parents: 4026
diff changeset
760 ;; call (point) and trivially get the byte offset in the file.
5b55fa103aa1 [xemacs-hg @ 2007-08-21 12:38:57 by aidan]
aidan
parents: 4026
diff changeset
761 ;;
4623
a9f83990e6bf Fix a byte compiler bug with characters above ?\xFF.
Aidan Kehoe <kehoea@parhasard.net>
parents: 4620
diff changeset
762 ;; And to unconditionally turn those two features off, you need to know
a9f83990e6bf Fix a byte compiler bug with characters above ?\xFF.
Aidan Kehoe <kehoea@parhasard.net>
parents: 4620
diff changeset
763 ;; before byte-compilation whether the byte-compilation output file
a9f83990e6bf Fix a byte compiler bug with characters above ?\xFF.
Aidan Kehoe <kehoea@parhasard.net>
parents: 4620
diff changeset
764 ;; contains non-Latin-1 characters. Or to check after compilation and
a9f83990e6bf Fix a byte compiler bug with characters above ?\xFF.
Aidan Kehoe <kehoea@parhasard.net>
parents: 4620
diff changeset
765 ;; redo; the latter is what we do right now. This will only be necessary
a9f83990e6bf Fix a byte compiler bug with characters above ?\xFF.
Aidan Kehoe <kehoea@parhasard.net>
parents: 4620
diff changeset
766 ;; in a very small minority of cases, it's not a performance-critical
a9f83990e6bf Fix a byte compiler bug with characters above ?\xFF.
Aidan Kehoe <kehoea@parhasard.net>
parents: 4620
diff changeset
767 ;; issue.
4133
5b55fa103aa1 [xemacs-hg @ 2007-08-21 12:38:57 by aidan]
aidan
parents: 4026
diff changeset
768 ;;
4623
a9f83990e6bf Fix a byte compiler bug with characters above ?\xFF.
Aidan Kehoe <kehoea@parhasard.net>
parents: 4620
diff changeset
769 ;; Martin Buchholz thinks, in bytecomp.el, that we should implement lazy
a9f83990e6bf Fix a byte compiler bug with characters above ?\xFF.
Aidan Kehoe <kehoea@parhasard.net>
parents: 4620
diff changeset
770 ;; loading for Mule files; I (Aidan Kehoe) don't think that's worth the
a9f83990e6bf Fix a byte compiler bug with characters above ?\xFF.
Aidan Kehoe <kehoea@parhasard.net>
parents: 4620
diff changeset
771 ;; effort today (February 2009).
3948
adecfd791c9b [xemacs-hg @ 2007-05-12 10:17:00 by aidan]
aidan
parents: 3927
diff changeset
772 (insert
4133
5b55fa103aa1 [xemacs-hg @ 2007-08-21 12:38:57 by aidan]
aidan
parents: 4026
diff changeset
773 "(defvar testing-mule-compilation-handling (eval-when-compile
5b55fa103aa1 [xemacs-hg @ 2007-08-21 12:38:57 by aidan]
aidan
parents: 4026
diff changeset
774 (decode-char 'ucs #x371e))) ;; kDefinition beautiful; pretty, used\"")
4623
a9f83990e6bf Fix a byte compiler bug with characters above ?\xFF.
Aidan Kehoe <kehoea@parhasard.net>
parents: 4620
diff changeset
775 (Assert-elc-is-escape-quoted)
3948
adecfd791c9b [xemacs-hg @ 2007-05-12 10:17:00 by aidan]
aidan
parents: 3927
diff changeset
776 (delete-region (point-min) (point-max))))
4318
4d0f773d5e21 Fix the test failures introduced by the non-ISO-2022 coding systems.
Aidan Kehoe <kehoea@parhasard.net>
parents: 4305
diff changeset
777
4d0f773d5e21 Fix the test failures introduced by the non-ISO-2022 coding systems.
Aidan Kehoe <kehoea@parhasard.net>
parents: 4305
diff changeset
778 (Known-Bug-Expect-Error
4d0f773d5e21 Fix the test failures introduced by the non-ISO-2022 coding systems.
Aidan Kehoe <kehoea@parhasard.net>
parents: 4305
diff changeset
779 invalid-constant
4d0f773d5e21 Fix the test failures introduced by the non-ISO-2022 coding systems.
Aidan Kehoe <kehoea@parhasard.net>
parents: 4305
diff changeset
780 (loop
4d0f773d5e21 Fix the test failures introduced by the non-ISO-2022 coding systems.
Aidan Kehoe <kehoea@parhasard.net>
parents: 4305
diff changeset
781 for i from #x0 to #x10FFFF
4d0f773d5e21 Fix the test failures introduced by the non-ISO-2022 coding systems.
Aidan Kehoe <kehoea@parhasard.net>
parents: 4305
diff changeset
782 with exceptions = #s(range-table type start-closed-end-closed
4d0f773d5e21 Fix the test failures introduced by the non-ISO-2022 coding systems.
Aidan Kehoe <kehoea@parhasard.net>
parents: 4305
diff changeset
783 data ((#xFFFE #xFFFF) t
4d0f773d5e21 Fix the test failures introduced by the non-ISO-2022 coding systems.
Aidan Kehoe <kehoea@parhasard.net>
parents: 4305
diff changeset
784 (#xFDD0 #xFDEF) t
4d0f773d5e21 Fix the test failures introduced by the non-ISO-2022 coding systems.
Aidan Kehoe <kehoea@parhasard.net>
parents: 4305
diff changeset
785 (#xD800 #xDBFF) t
4d0f773d5e21 Fix the test failures introduced by the non-ISO-2022 coding systems.
Aidan Kehoe <kehoea@parhasard.net>
parents: 4305
diff changeset
786 (#xDC00 #xDFFF) t))
4d0f773d5e21 Fix the test failures introduced by the non-ISO-2022 coding systems.
Aidan Kehoe <kehoea@parhasard.net>
parents: 4305
diff changeset
787 do (unless (get-range-table i exceptions)
4d0f773d5e21 Fix the test failures introduced by the non-ISO-2022 coding systems.
Aidan Kehoe <kehoea@parhasard.net>
parents: 4305
diff changeset
788 (read (format (if (> i #xFFFF) #r"?\U%08X" #r"?\u%04X") i)))
4d0f773d5e21 Fix the test failures introduced by the non-ISO-2022 coding systems.
Aidan Kehoe <kehoea@parhasard.net>
parents: 4305
diff changeset
789 finally return t))
4688
7e54adf407a1 Fix a bug with Unicode error sequences and very short input strings.
Aidan Kehoe <kehoea@parhasard.net>
parents: 4672
diff changeset
790 (loop
7e54adf407a1 Fix a bug with Unicode error sequences and very short input strings.
Aidan Kehoe <kehoea@parhasard.net>
parents: 4672
diff changeset
791 for i from #x00 to #xff
7e54adf407a1 Fix a bug with Unicode error sequences and very short input strings.
Aidan Kehoe <kehoea@parhasard.net>
parents: 4672
diff changeset
792 do (Assert
7e54adf407a1 Fix a bug with Unicode error sequences and very short input strings.
Aidan Kehoe <kehoea@parhasard.net>
parents: 4672
diff changeset
793 (= 1 (length (decode-coding-string (format "%c" i) 'utf-8-unix)))
7e54adf407a1 Fix a bug with Unicode error sequences and very short input strings.
Aidan Kehoe <kehoea@parhasard.net>
parents: 4672
diff changeset
794 (format
7e54adf407a1 Fix a bug with Unicode error sequences and very short input strings.
Aidan Kehoe <kehoea@parhasard.net>
parents: 4672
diff changeset
795 "checking Unicode coding systems behave well with short input, %02X"
7e54adf407a1 Fix a bug with Unicode error sequences and very short input strings.
Aidan Kehoe <kehoea@parhasard.net>
parents: 4672
diff changeset
796 i)))
4731
ad40dc9d3a97 Add test of nil binding of default-process-coding-system.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4715
diff changeset
797
ad40dc9d3a97 Add test of nil binding of default-process-coding-system.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4715
diff changeset
798 ;;---------------------------------------------------------------
ad40dc9d3a97 Add test of nil binding of default-process-coding-system.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4715
diff changeset
799 ;; Process tests
ad40dc9d3a97 Add test of nil binding of default-process-coding-system.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4715
diff changeset
800 ;; #### Should do network too.
ad40dc9d3a97 Add test of nil binding of default-process-coding-system.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4715
diff changeset
801 ;;---------------------------------------------------------------
ad40dc9d3a97 Add test of nil binding of default-process-coding-system.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4715
diff changeset
802 (Skip-Test-Unless (and (file-exists-p "/dev/null")
ad40dc9d3a97 Add test of nil binding of default-process-coding-system.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4715
diff changeset
803 (fboundp 'executable-find)
ad40dc9d3a97 Add test of nil binding of default-process-coding-system.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4715
diff changeset
804 (executable-find "cat"))
ad40dc9d3a97 Add test of nil binding of default-process-coding-system.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4715
diff changeset
805 "cat(1) or /dev/null missing"
ad40dc9d3a97 Add test of nil binding of default-process-coding-system.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4715
diff changeset
806 "Test that default-process-coding-system can be nil."
ad40dc9d3a97 Add test of nil binding of default-process-coding-system.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4715
diff changeset
807 (with-temp-buffer
ad40dc9d3a97 Add test of nil binding of default-process-coding-system.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4715
diff changeset
808 (Assert (let (default-process-coding-system)
ad40dc9d3a97 Add test of nil binding of default-process-coding-system.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4715
diff changeset
809 (shell-command "cat </dev/null >/dev/null")
ad40dc9d3a97 Add test of nil binding of default-process-coding-system.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4715
diff changeset
810 t))))
5664
00fd55d635fb Sync #'truncate-string-to-width with GNU, add tests for it.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5595
diff changeset
811 ;;; Test suite for truncate-string-to-width, from Colin Walters' tests in
00fd55d635fb Sync #'truncate-string-to-width with GNU, add tests for it.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5595
diff changeset
812 ;;; mult-util.el in GNU.
00fd55d635fb Sync #'truncate-string-to-width with GNU, add tests for it.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5595
diff changeset
813 (macrolet
00fd55d635fb Sync #'truncate-string-to-width with GNU, add tests for it.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5595
diff changeset
814 ((test-truncate-string-to-width (&rest tests)
00fd55d635fb Sync #'truncate-string-to-width with GNU, add tests for it.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5595
diff changeset
815 (let ((decode-any-string
00fd55d635fb Sync #'truncate-string-to-width with GNU, add tests for it.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5595
diff changeset
816 ;; We can't store the East Asian characters directly in this
00fd55d635fb Sync #'truncate-string-to-width with GNU, add tests for it.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5595
diff changeset
817 ;; file, since it needs to be read (but not executed) by
00fd55d635fb Sync #'truncate-string-to-width with GNU, add tests for it.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5595
diff changeset
818 ;; non-Mule. Store them as UTF-8, decode them at
00fd55d635fb Sync #'truncate-string-to-width with GNU, add tests for it.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5595
diff changeset
819 ;; macro-expansion time.
00fd55d635fb Sync #'truncate-string-to-width with GNU, add tests for it.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5595
diff changeset
820 #'(lambda (object)
00fd55d635fb Sync #'truncate-string-to-width with GNU, add tests for it.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5595
diff changeset
821 (if (stringp object)
00fd55d635fb Sync #'truncate-string-to-width with GNU, add tests for it.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5595
diff changeset
822 (decode-coding-string object 'utf-8)
00fd55d635fb Sync #'truncate-string-to-width with GNU, add tests for it.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5595
diff changeset
823 object))))
00fd55d635fb Sync #'truncate-string-to-width with GNU, add tests for it.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5595
diff changeset
824 (cons
00fd55d635fb Sync #'truncate-string-to-width with GNU, add tests for it.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5595
diff changeset
825 'progn
00fd55d635fb Sync #'truncate-string-to-width with GNU, add tests for it.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5595
diff changeset
826 (mapcar
00fd55d635fb Sync #'truncate-string-to-width with GNU, add tests for it.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5595
diff changeset
827 (function*
00fd55d635fb Sync #'truncate-string-to-width with GNU, add tests for it.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5595
diff changeset
828 (lambda ((arguments . result))
00fd55d635fb Sync #'truncate-string-to-width with GNU, add tests for it.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5595
diff changeset
829 `(Assert (equal (truncate-string-to-width
00fd55d635fb Sync #'truncate-string-to-width with GNU, add tests for it.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5595
diff changeset
830 ,@(mapcar decode-any-string arguments))
00fd55d635fb Sync #'truncate-string-to-width with GNU, add tests for it.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5595
diff changeset
831 ,(funcall decode-any-string result)))))
00fd55d635fb Sync #'truncate-string-to-width with GNU, add tests for it.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5595
diff changeset
832 tests)))))
00fd55d635fb Sync #'truncate-string-to-width with GNU, add tests for it.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5595
diff changeset
833 (test-truncate-string-to-width
00fd55d635fb Sync #'truncate-string-to-width with GNU, add tests for it.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5595
diff changeset
834 (("" 0) . "")
00fd55d635fb Sync #'truncate-string-to-width with GNU, add tests for it.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5595
diff changeset
835 (("x" 1) . "x")
00fd55d635fb Sync #'truncate-string-to-width with GNU, add tests for it.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5595
diff changeset
836 (("xy" 1) . "x")
00fd55d635fb Sync #'truncate-string-to-width with GNU, add tests for it.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5595
diff changeset
837 (("xy" 2 1) . "y")
00fd55d635fb Sync #'truncate-string-to-width with GNU, add tests for it.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5595
diff changeset
838 (("xy" 0) . "")
00fd55d635fb Sync #'truncate-string-to-width with GNU, add tests for it.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5595
diff changeset
839 (("xy" 3) . "xy")
00fd55d635fb Sync #'truncate-string-to-width with GNU, add tests for it.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5595
diff changeset
840 (("\344\270\255" 0) . "")
00fd55d635fb Sync #'truncate-string-to-width with GNU, add tests for it.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5595
diff changeset
841 (("\344\270\255" 1) . "")
00fd55d635fb Sync #'truncate-string-to-width with GNU, add tests for it.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5595
diff changeset
842 (("\344\270\255" 2) . "\344\270\255")
00fd55d635fb Sync #'truncate-string-to-width with GNU, add tests for it.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5595
diff changeset
843 (("\344\270\255" 1 nil ? ) . " ")
00fd55d635fb Sync #'truncate-string-to-width with GNU, add tests for it.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5595
diff changeset
844 (("\344\270\255\346\226\207" 3 1 ? ) . " ")
00fd55d635fb Sync #'truncate-string-to-width with GNU, add tests for it.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5595
diff changeset
845 (("x\344\270\255x" 2) . "x")
00fd55d635fb Sync #'truncate-string-to-width with GNU, add tests for it.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5595
diff changeset
846 (("x\344\270\255x" 3) . "x\344\270\255")
00fd55d635fb Sync #'truncate-string-to-width with GNU, add tests for it.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5595
diff changeset
847 (("x\344\270\255x" 3) . "x\344\270\255")
00fd55d635fb Sync #'truncate-string-to-width with GNU, add tests for it.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5595
diff changeset
848 (("x\344\270\255x" 4 1) . "\344\270\255x")
00fd55d635fb Sync #'truncate-string-to-width with GNU, add tests for it.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5595
diff changeset
849 (("kor\355\225\234e\352\270\200an" 8 1 ? ) .
00fd55d635fb Sync #'truncate-string-to-width with GNU, add tests for it.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5595
diff changeset
850 "or\355\225\234e\352\270\200")
00fd55d635fb Sync #'truncate-string-to-width with GNU, add tests for it.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5595
diff changeset
851 (("kor\355\225\234e\352\270\200an" 7 2 ? ) . "r\355\225\234e ")
00fd55d635fb Sync #'truncate-string-to-width with GNU, add tests for it.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5595
diff changeset
852 (("" 0 nil nil "...") . "")
00fd55d635fb Sync #'truncate-string-to-width with GNU, add tests for it.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5595
diff changeset
853 (("x" 3 nil nil "...") . "x")
00fd55d635fb Sync #'truncate-string-to-width with GNU, add tests for it.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5595
diff changeset
854 (("\344\270\255" 3 nil nil "...") . "\344\270\255")
00fd55d635fb Sync #'truncate-string-to-width with GNU, add tests for it.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5595
diff changeset
855 (("foo" 3 nil nil "...") . "foo")
00fd55d635fb Sync #'truncate-string-to-width with GNU, add tests for it.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5595
diff changeset
856 (("foo" 2 nil nil "...") . "fo") ;; (old) XEmacs failure?
00fd55d635fb Sync #'truncate-string-to-width with GNU, add tests for it.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5595
diff changeset
857 (("foobar" 6 0 nil "...") . "foobar")
00fd55d635fb Sync #'truncate-string-to-width with GNU, add tests for it.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5595
diff changeset
858 (("foobarbaz" 6 nil nil "...") . "foo...")
00fd55d635fb Sync #'truncate-string-to-width with GNU, add tests for it.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5595
diff changeset
859 (("foobarbaz" 7 2 nil "...") . "ob...")
00fd55d635fb Sync #'truncate-string-to-width with GNU, add tests for it.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5595
diff changeset
860 (("foobarbaz" 9 3 nil "...") . "barbaz")
00fd55d635fb Sync #'truncate-string-to-width with GNU, add tests for it.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5595
diff changeset
861 (("\343\201\223h\343\202\223e\343\201\253l\343\201\241l\343\201\257o" 15
00fd55d635fb Sync #'truncate-string-to-width with GNU, add tests for it.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5595
diff changeset
862 1 ? t) . " h\343\202\223e\343\201\253l\343\201\241l\343\201\257o")
00fd55d635fb Sync #'truncate-string-to-width with GNU, add tests for it.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5595
diff changeset
863 (("\343\201\223h\343\202\223e\343\201\253l\343\201\241l\343\201\257o" 14
00fd55d635fb Sync #'truncate-string-to-width with GNU, add tests for it.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5595
diff changeset
864 1 ? t) . " h\343\202\223e\343\201\253l\343\201\241...")
00fd55d635fb Sync #'truncate-string-to-width with GNU, add tests for it.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5595
diff changeset
865 (("x" 3 nil nil "\347\262\265\350\252\236") . "x")
00fd55d635fb Sync #'truncate-string-to-width with GNU, add tests for it.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5595
diff changeset
866 (("\344\270\255" 2 nil nil "\347\262\265\350\252\236") . "\344\270\255")
00fd55d635fb Sync #'truncate-string-to-width with GNU, add tests for it.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5595
diff changeset
867 ;; XEmacs used to error
00fd55d635fb Sync #'truncate-string-to-width with GNU, add tests for it.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5595
diff changeset
868 (("\344\270\255" 1 nil ?x "\347\262\265\350\252\236") . "x")
00fd55d635fb Sync #'truncate-string-to-width with GNU, add tests for it.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5595
diff changeset
869 (("\344\270\255\346\226\207" 3 nil ? "\347\262\265\350\252\236") .
00fd55d635fb Sync #'truncate-string-to-width with GNU, add tests for it.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5595
diff changeset
870 ;; XEmacs used to error
00fd55d635fb Sync #'truncate-string-to-width with GNU, add tests for it.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5595
diff changeset
871 "\344\270\255 ")
00fd55d635fb Sync #'truncate-string-to-width with GNU, add tests for it.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5595
diff changeset
872 (("foobarbaz" 4 nil nil "\347\262\265\350\252\236") .
00fd55d635fb Sync #'truncate-string-to-width with GNU, add tests for it.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5595
diff changeset
873 "\347\262\265\350\252\236")
00fd55d635fb Sync #'truncate-string-to-width with GNU, add tests for it.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5595
diff changeset
874 (("foobarbaz" 5 nil nil "\347\262\265\350\252\236") .
00fd55d635fb Sync #'truncate-string-to-width with GNU, add tests for it.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5595
diff changeset
875 "f\347\262\265\350\252\236")
00fd55d635fb Sync #'truncate-string-to-width with GNU, add tests for it.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5595
diff changeset
876 (("foobarbaz" 6 nil nil "\347\262\265\350\252\236") .
00fd55d635fb Sync #'truncate-string-to-width with GNU, add tests for it.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5595
diff changeset
877 "fo\347\262\265\350\252\236")
00fd55d635fb Sync #'truncate-string-to-width with GNU, add tests for it.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5595
diff changeset
878 (("foobarbaz" 8 3 nil "\347\262\265\350\252\236") .
00fd55d635fb Sync #'truncate-string-to-width with GNU, add tests for it.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5595
diff changeset
879 "b\347\262\265\350\252\236")
00fd55d635fb Sync #'truncate-string-to-width with GNU, add tests for it.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5595
diff changeset
880 (("\343\201\223h\343\202\223e\343\201\253l\343\201\241l\343\201\257o" 14
00fd55d635fb Sync #'truncate-string-to-width with GNU, add tests for it.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5595
diff changeset
881 4 ?x "\346\227\245\346\234\254\350\252\236") .
00fd55d635fb Sync #'truncate-string-to-width with GNU, add tests for it.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5595
diff changeset
882 "xe\343\201\253\346\227\245\346\234\254\350\252\236")
00fd55d635fb Sync #'truncate-string-to-width with GNU, add tests for it.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5595
diff changeset
883 (("\343\201\223h\343\202\223e\343\201\253l\343\201\241l\343\201\257o" 13
00fd55d635fb Sync #'truncate-string-to-width with GNU, add tests for it.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5595
diff changeset
884 4 ?x "\346\227\245\346\234\254\350\252\236") .
00fd55d635fb Sync #'truncate-string-to-width with GNU, add tests for it.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5595
diff changeset
885 "xex\346\227\245\346\234\254\350\252\236")))
4731
ad40dc9d3a97 Add test of nil binding of default-process-coding-system.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4715
diff changeset
886 ) ; end of tests that require MULE built in.
ad40dc9d3a97 Add test of nil binding of default-process-coding-system.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4715
diff changeset
887
ad40dc9d3a97 Add test of nil binding of default-process-coding-system.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4715
diff changeset
888 ;;; end of mule-tests.el