annotate tests/automated/mule-tests.el @ 398:74fd4e045ea6 r21-2-29

Import from CVS: tag r21-2-29
author cvs
date Mon, 13 Aug 2007 11:13:30 +0200
parents
children a86b2b5e0111
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
1 ;; Copyright (C) 1999 Free Software Foundation, Inc.
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
2
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
3 ;; Author: Hrvoje Niksic <hniksic@xemacs.org>
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
4 ;; Maintainers: Hrvoje Niksic <hniksic@xemacs.org>,
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
5 ;; Martin Buchholz <martin@xemacs.org>
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
6 ;; Created: 1999
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
7 ;; Keywords: tests
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
8
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
9 ;; This file is part of XEmacs.
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
10
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
11 ;; XEmacs is free software; you can redistribute it and/or modify it
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
12 ;; under the terms of the GNU General Public License as published by
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
13 ;; the Free Software Foundation; either version 2, or (at your option)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
14 ;; any later version.
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
15
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
16 ;; XEmacs is distributed in the hope that it will be useful, but
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
17 ;; WITHOUT ANY WARRANTY; without even the implied warranty of
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
19 ;; General Public License for more details.
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
20
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
21 ;; You should have received a copy of the GNU General Public License
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
22 ;; along with XEmacs; see the file COPYING. If not, write to the Free
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
23 ;; Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
24 ;; 02111-1307, USA.
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
25
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
26 ;;; Synched up with: Not in FSF.
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
27
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
28 ;;; Commentary:
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
29
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
30 ;; Test some Mule functionality (most of these remain to be written) .
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
31 ;; See test-harness.el for instructions on how to run these tests.
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
32
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
33 ;; This file will be (read)ed by a non-mule XEmacs, so don't use
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
34 ;; literal non-Latin1 characters. Use (make-char) instead.
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
35
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
36 ;;-----------------------------------------------------------------
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
37 ;; Test whether all legal chars may be safely inserted to a buffer.
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
38 ;;-----------------------------------------------------------------
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
39
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
40 (defun test-chars (&optional for-test-harness)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
41 "Insert all characters in a buffer, to see if XEmacs will crash.
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
42 This is done by creating a string with all the legal characters
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
43 in [0, 2^19) range, inserting it into the buffer, and checking
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
44 that the buffer's contents are equivalent to the string.
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
45
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
46 If FOR-TEST-HARNESS is specified, a temporary buffer is used, and
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
47 the Assert macro checks for correctness."
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
48 (let ((max (expt 2 (if (featurep 'mule) 19 8)))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
49 (list nil)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
50 (i 0))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
51 (while (< i max)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
52 (and (not for-test-harness)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
53 (zerop (% i 1000))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
54 (message "%d" i))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
55 (and (int-char i)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
56 ;; Don't aset to a string directly because random string
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
57 ;; access is O(n) under Mule.
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
58 (setq list (cons (int-char i) list)))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
59 (setq i (1+ i)))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
60 (let ((string (apply #'string (nreverse list))))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
61 (if for-test-harness
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
62 ;; For use with test-harness, use Assert and a temporary
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
63 ;; buffer.
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
64 (with-temp-buffer
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
65 (insert string)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
66 (Assert (equal (buffer-string) string)))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
67 ;; For use without test harness: use a normal buffer, so that
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
68 ;; you can also test whether redisplay works.
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
69 (switch-to-buffer (get-buffer-create "test"))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
70 (erase-buffer)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
71 (buffer-disable-undo)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
72 (insert string)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
73 (assert (equal (buffer-string) string))))))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
74
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
75 ;; It would be really *really* nice if test-harness allowed a way to
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
76 ;; run a test in byte-compiled mode only. It's tedious to have
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
77 ;; time-consuming tests like this one run twice, once interpreted and
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
78 ;; once compiled, for no good reason.
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
79 (test-chars t)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
80
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
81 ;;-----------------------------------------------------------------
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
82 ;; Test string modification functions that modify the length of a char.
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
83 ;;-----------------------------------------------------------------
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
84
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
85 (when (featurep 'mule)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
86 ;; Test fillarray
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
87 (macrolet
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
88 ((fillarray-test
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
89 (charset1 charset2)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
90 (let ((char1 (make-char charset1 69))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
91 (char2 (make-char charset2 69)))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
92 `(let ((string (make-string 1000 ,char1)))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
93 (fillarray string ,char2)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
94 (Assert (eq (aref string 0) ,char2))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
95 (Assert (eq (aref string (1- (length string))) ,char2))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
96 (Assert (eq (length string) 1000))))))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
97 (fillarray-test ascii latin-iso8859-1)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
98 (fillarray-test ascii latin-iso8859-2)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
99 (fillarray-test latin-iso8859-1 ascii)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
100 (fillarray-test latin-iso8859-2 ascii))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
101
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
102 ;; Test aset
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
103 (let ((string (string (make-char 'ascii 69) (make-char 'latin-iso8859-2 69))))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
104 (aset string 0 (make-char 'latin-iso8859-2 42))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
105 (Assert (eq (aref string 1) (make-char 'latin-iso8859-2 69))))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
106
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
107 ;; Test coding system functions
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
108
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
109 ;; Create alias for coding system without subsidiaries
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
110 (Assert (coding-system-p (find-coding-system 'binary)))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
111 (Assert (coding-system-canonical-name-p 'binary))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
112 (Assert (not (coding-system-alias-p 'binary)))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
113 (Assert (not (coding-system-alias-p 'mule-tests-alias)))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
114 (Assert (not (coding-system-canonical-name-p 'mule-tests-alias)))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
115 (Check-Error-Message
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
116 error "Symbol is the canonical name of a coding system and cannot be redefined"
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
117 (define-coding-system-alias 'binary 'iso8859-2))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
118 (Check-Error-Message
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
119 error "Symbol is not a coding system alias"
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
120 (coding-system-aliasee 'binary))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
121
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
122 (define-coding-system-alias 'mule-tests-alias 'binary)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
123 (Assert (coding-system-alias-p 'mule-tests-alias))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
124 (Assert (not (coding-system-canonical-name-p 'mule-tests-alias)))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
125 (Assert (eq (get-coding-system 'binary) (get-coding-system 'mule-tests-alias)))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
126 (Assert (eq 'binary (coding-system-aliasee 'mule-tests-alias)))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
127 (Assert (not (coding-system-alias-p 'mule-tests-alias-unix)))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
128 (Assert (not (coding-system-alias-p 'mule-tests-alias-dos)))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
129 (Assert (not (coding-system-alias-p 'mule-tests-alias-mac)))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
130
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
131 (define-coding-system-alias 'mule-tests-alias (get-coding-system 'binary))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
132 (Assert (coding-system-alias-p 'mule-tests-alias))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
133 (Assert (not (coding-system-canonical-name-p 'mule-tests-alias)))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
134 (Assert (eq (get-coding-system 'binary) (get-coding-system 'mule-tests-alias)))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
135 (Assert (eq 'binary (coding-system-aliasee 'mule-tests-alias)))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
136 (Assert (not (coding-system-alias-p 'mule-tests-alias-unix)))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
137 (Assert (not (coding-system-alias-p 'mule-tests-alias-dos)))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
138 (Assert (not (coding-system-alias-p 'mule-tests-alias-mac)))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
139
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
140 (define-coding-system-alias 'nested-mule-tests-alias 'mule-tests-alias)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
141 (Assert (coding-system-alias-p 'nested-mule-tests-alias))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
142 (Assert (not (coding-system-canonical-name-p 'nested-mule-tests-alias)))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
143 (Assert (eq (get-coding-system 'binary) (get-coding-system 'nested-mule-tests-alias)))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
144 (Assert (eq (coding-system-aliasee 'nested-mule-tests-alias) 'mule-tests-alias))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
145 (Assert (eq 'mule-tests-alias (coding-system-aliasee 'nested-mule-tests-alias)))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
146 (Assert (not (coding-system-alias-p 'nested-mule-tests-alias-unix)))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
147 (Assert (not (coding-system-alias-p 'nested-mule-tests-alias-dos)))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
148 (Assert (not (coding-system-alias-p 'nested-mule-tests-alias-mac)))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
149
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
150 (Check-Error-Message
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
151 error "Attempt to create a coding system alias loop"
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
152 (define-coding-system-alias 'mule-tests-alias 'nested-mule-tests-alias))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
153 (Check-Error-Message
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
154 error "No such coding system"
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
155 (define-coding-system-alias 'no-such-coding-system 'no-such-coding-system))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
156 (Check-Error-Message
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
157 error "Attempt to create a coding system alias loop"
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
158 (define-coding-system-alias 'mule-tests-alias 'mule-tests-alias))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
159
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
160 (define-coding-system-alias 'nested-mule-tests-alias nil)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
161 (define-coding-system-alias 'mule-tests-alias nil)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
162 (Assert (coding-system-p (find-coding-system 'binary)))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
163 (Assert (coding-system-canonical-name-p 'binary))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
164 (Assert (not (coding-system-alias-p 'binary)))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
165 (Assert (not (coding-system-alias-p 'mule-tests-alias)))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
166 (Assert (not (coding-system-canonical-name-p 'mule-tests-alias)))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
167 (Check-Error-Message
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
168 error "Symbol is the canonical name of a coding system and cannot be redefined"
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
169 (define-coding-system-alias 'binary 'iso8859-2))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
170 (Check-Error-Message
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
171 error "Symbol is not a coding system alias"
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
172 (coding-system-aliasee 'binary))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
173
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
174 (define-coding-system-alias 'nested-mule-tests-alias nil)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
175 (define-coding-system-alias 'mule-tests-alias nil)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
176
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
177 ;; Create alias for coding system with subsidiaries
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
178 (define-coding-system-alias 'mule-tests-alias 'iso-8859-7)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
179 (Assert (coding-system-alias-p 'mule-tests-alias))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
180 (Assert (not (coding-system-canonical-name-p 'mule-tests-alias)))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
181 (Assert (eq (get-coding-system 'iso-8859-7) (get-coding-system 'mule-tests-alias)))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
182 (Assert (eq 'iso-8859-7 (coding-system-aliasee 'mule-tests-alias)))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
183 (Assert (coding-system-alias-p 'mule-tests-alias-unix))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
184 (Assert (coding-system-alias-p 'mule-tests-alias-dos))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
185 (Assert (coding-system-alias-p 'mule-tests-alias-mac))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
186
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
187 (define-coding-system-alias 'mule-tests-alias (get-coding-system 'iso-8859-7))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
188 (Assert (coding-system-alias-p 'mule-tests-alias))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
189 (Assert (not (coding-system-canonical-name-p 'mule-tests-alias)))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
190 (Assert (eq (get-coding-system 'iso-8859-7) (get-coding-system 'mule-tests-alias)))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
191 (Assert (eq 'iso-8859-7 (coding-system-aliasee 'mule-tests-alias)))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
192 (Assert (coding-system-alias-p 'mule-tests-alias-unix))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
193 (Assert (coding-system-alias-p 'mule-tests-alias-dos))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
194 (Assert (coding-system-alias-p 'mule-tests-alias-mac))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
195 (Assert (eq (find-coding-system 'mule-tests-alias-mac)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
196 (find-coding-system 'iso-8859-7-mac)))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
197
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
198 (define-coding-system-alias 'nested-mule-tests-alias 'mule-tests-alias)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
199 (Assert (coding-system-alias-p 'nested-mule-tests-alias))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
200 (Assert (not (coding-system-canonical-name-p 'nested-mule-tests-alias)))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
201 (Assert (eq (get-coding-system 'iso-8859-7)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
202 (get-coding-system 'nested-mule-tests-alias)))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
203 (Assert (eq (coding-system-aliasee 'nested-mule-tests-alias) 'mule-tests-alias))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
204 (Assert (eq 'mule-tests-alias (coding-system-aliasee 'nested-mule-tests-alias)))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
205 (Assert (coding-system-alias-p 'nested-mule-tests-alias-unix))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
206 (Assert (coding-system-alias-p 'nested-mule-tests-alias-dos))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
207 (Assert (coding-system-alias-p 'nested-mule-tests-alias-mac))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
208 (Assert (eq (find-coding-system 'nested-mule-tests-alias-unix)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
209 (find-coding-system 'iso-8859-7-unix)))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
210
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
211 (Check-Error-Message
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
212 error "Attempt to create a coding system alias loop"
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
213 (define-coding-system-alias 'mule-tests-alias 'nested-mule-tests-alias))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
214 (Check-Error-Message
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
215 error "No such coding system"
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
216 (define-coding-system-alias 'no-such-coding-system 'no-such-coding-system))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
217 (Check-Error-Message
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
218 error "Attempt to create a coding system alias loop"
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
219 (define-coding-system-alias 'mule-tests-alias 'mule-tests-alias))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
220
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
221 ;; Test dangling alias deletion
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
222 (define-coding-system-alias 'mule-tests-alias nil)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
223 (Assert (not (coding-system-alias-p 'mule-tests-alias)))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
224 (Assert (not (coding-system-alias-p 'mule-tests-alias-unix)))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
225 (Assert (not (coding-system-alias-p 'nested-mule-tests-alias)))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
226 (Assert (not (coding-system-alias-p 'nested-mule-tests-alias-dos)))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
227
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
228 ;; Test strings waxing and waning across the 8k BIG_STRING limit (see alloc.c)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
229 (defun charset-char-string (charset)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
230 (let (lo hi string n)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
231 (if (= (charset-chars charset) 94)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
232 (setq lo 33 hi 126)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
233 (setq lo 32 hi 127))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
234 (if (= (charset-dimension charset) 1)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
235 (progn
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
236 (setq string (make-string (1+ (- hi lo)) ??))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
237 (setq n 0)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
238 (loop for j from lo to hi do
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
239 (progn
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
240 (aset string n (make-char charset j))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
241 (incf n)))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
242 string)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
243 (progn
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
244 (setq string (make-string (* (1+ (- hi lo)) (1+ (- hi lo))) ??))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
245 (setq n 0)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
246 (loop for j from lo to hi do
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
247 (loop for k from lo to hi do
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
248 (progn
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
249 (aset string n (make-char charset j k))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
250 (incf n))))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
251 string))))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
252
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
253 ;; The following two used to crash xemacs!
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
254 (Assert (charset-char-string 'japanese-jisx0208))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
255 (aset (make-string 9003 ??) 1 (make-char 'latin-iso8859-1 77))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
256
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
257 (let ((greek-string (charset-char-string 'greek-iso8859-7))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
258 (string (make-string (* 96 60) ??)))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
259 (loop for j from 0 below (length string) do
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
260 (aset string j (aref greek-string (mod j 96))))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
261 (loop for k in '(0 1 58 59) do
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
262 (Assert (equal (substring string (* 96 k) (* 96 (1+ k))) greek-string))))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
263
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
264 (let ((greek-string (charset-char-string 'greek-iso8859-7))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
265 (string (make-string (* 96 60) ??)))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
266 (loop for j from (1- (length string)) downto 0 do
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
267 (aset string j (aref greek-string (mod j 96))))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
268 (loop for k in '(0 1 58 59) do
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
269 (Assert (equal (substring string (* 96 k) (* 96 (1+ k))) greek-string))))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
270
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
271 (let ((ascii-string (charset-char-string 'ascii))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
272 (string (make-string (* 94 60) (make-char 'greek-iso8859-7 57))))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
273 (loop for j from 0 below (length string) do
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
274 (aset string j (aref ascii-string (mod j 94))))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
275 (loop for k in '(0 1 58 59) do
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
276 (Assert (equal (substring string (* 94 k) (+ 94 (* 94 k))) ascii-string))))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
277
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
278 (let ((ascii-string (charset-char-string 'ascii))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
279 (string (make-string (* 94 60) (make-char 'greek-iso8859-7 57))))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
280 (loop for j from (1- (length string)) downto 0 do
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
281 (aset string j (aref ascii-string (mod j 94))))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
282 (loop for k in '(0 1 58 59) do
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
283 (Assert (equal (substring string (* 94 k) (* 94 (1+ k))) ascii-string))))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
284
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
285 )