comparison tests/automated/mule-tests.el @ 4855:189fb67ca31a

Create Assert-eq, Assert-equal, etc. These are equivalent to (Assert (eq ...)) but display both the actual value and the expected value of the comparison. Use them throughout the test suite.
author Ben Wing <ben@xemacs.org>
date Thu, 14 Jan 2010 02:18:03 -0600
parents b3ea9c582280
children 1f3ed6288996
comparison
equal deleted inserted replaced
4854:95c4ced5c07c 4855:189fb67ca31a
63 (if for-test-harness 63 (if for-test-harness
64 ;; For use with test-harness, use Assert and a temporary 64 ;; For use with test-harness, use Assert and a temporary
65 ;; buffer. 65 ;; buffer.
66 (with-temp-buffer 66 (with-temp-buffer
67 (insert string) 67 (insert string)
68 (Assert (equal (buffer-string) string))) 68 (Assert-equal (buffer-string) string))
69 ;; For use without test harness: use a normal buffer, so that 69 ;; For use without test harness: use a normal buffer, so that
70 ;; you can also test whether redisplay works. 70 ;; you can also test whether redisplay works.
71 (switch-to-buffer (get-buffer-create "test")) 71 (switch-to-buffer (get-buffer-create "test"))
72 (erase-buffer) 72 (erase-buffer)
73 (buffer-disable-undo) 73 (buffer-disable-undo)
150 (coding-system-type buffer-file-coding-system)))) 150 (coding-system-type buffer-file-coding-system))))
151 (kill-buffer nil) 151 (kill-buffer nil)
152 (dolist (coding-system '(utf-8 windows-1251 macintosh big5)) 152 (dolist (coding-system '(utf-8 windows-1251 macintosh big5))
153 (when (find-coding-system coding-system) 153 (when (find-coding-system coding-system)
154 (find-file existing-file-name coding-system) 154 (find-file existing-file-name coding-system)
155 (Assert (eq (find-coding-system coding-system) 155 (Assert-eq (find-coding-system coding-system)
156 buffer-file-coding-system)) 156 buffer-file-coding-system)
157 (kill-buffer nil) 157 (kill-buffer nil)
158 (find-file nonexistent-file-name coding-system) 158 (find-file nonexistent-file-name coding-system)
159 (Assert (eq (find-coding-system coding-system) 159 (Assert-eq (find-coding-system coding-system)
160 buffer-file-coding-system)) 160 buffer-file-coding-system)
161 (set-buffer-modified-p nil) 161 (set-buffer-modified-p nil)
162 (kill-buffer nil))) 162 (kill-buffer nil)))
163 (delete-file existing-file-name)) 163 (delete-file existing-file-name))
164 164
165 ;;----------------------------------------------------------------- 165 ;;-----------------------------------------------------------------
175 (charset1 charset2) 175 (charset1 charset2)
176 (let ((char1 (make-char charset1 69)) 176 (let ((char1 (make-char charset1 69))
177 (char2 (make-char charset2 69))) 177 (char2 (make-char charset2 69)))
178 `(let ((string (make-string 1000 ,char1))) 178 `(let ((string (make-string 1000 ,char1)))
179 (fillarray string ,char2) 179 (fillarray string ,char2)
180 (Assert (eq (aref string 0) ,char2)) 180 (Assert-eq (aref string 0) ,char2)
181 (Assert (eq (aref string (1- (length string))) ,char2)) 181 (Assert-eq (aref string (1- (length string))) ,char2)
182 (Assert (eq (length string) 1000)))))) 182 (Assert-eq (length string) 1000)))))
183 (fillarray-test ascii latin-iso8859-1) 183 (fillarray-test ascii latin-iso8859-1)
184 (fillarray-test ascii latin-iso8859-2) 184 (fillarray-test ascii latin-iso8859-2)
185 (fillarray-test latin-iso8859-1 ascii) 185 (fillarray-test latin-iso8859-1 ascii)
186 (fillarray-test latin-iso8859-2 ascii)) 186 (fillarray-test latin-iso8859-2 ascii))
187 187
188 ;; Test aset 188 ;; Test aset
189 (let ((string (string (make-char 'ascii 69) (make-char 'latin-iso8859-2 69)))) 189 (let ((string (string (make-char 'ascii 69) (make-char 'latin-iso8859-2 69))))
190 (aset string 0 (make-char 'latin-iso8859-2 42)) 190 (aset string 0 (make-char 'latin-iso8859-2 42))
191 (Assert (eq (aref string 1) (make-char 'latin-iso8859-2 69)))) 191 (Assert-eq (aref string 1) (make-char 'latin-iso8859-2 69)))
192 192
193 ;;--------------------------------------------------------------- 193 ;;---------------------------------------------------------------
194 ;; Test coding system functions 194 ;; Test coding system functions
195 ;;--------------------------------------------------------------- 195 ;;---------------------------------------------------------------
196 196
208 (coding-system-aliasee 'binary)) 208 (coding-system-aliasee 'binary))
209 209
210 (define-coding-system-alias 'mule-tests-alias 'binary) 210 (define-coding-system-alias 'mule-tests-alias 'binary)
211 (Assert (coding-system-alias-p 'mule-tests-alias)) 211 (Assert (coding-system-alias-p 'mule-tests-alias))
212 (Assert (not (coding-system-canonical-name-p 'mule-tests-alias))) 212 (Assert (not (coding-system-canonical-name-p 'mule-tests-alias)))
213 (Assert (eq (get-coding-system 'binary) (get-coding-system 'mule-tests-alias))) 213 (Assert-eq (get-coding-system 'binary) (get-coding-system 'mule-tests-alias))
214 (Assert (eq 'binary (coding-system-aliasee 'mule-tests-alias))) 214 (Assert-eq 'binary (coding-system-aliasee 'mule-tests-alias))
215 (Assert (not (coding-system-alias-p 'mule-tests-alias-unix))) 215 (Assert (not (coding-system-alias-p 'mule-tests-alias-unix)))
216 (Assert (not (coding-system-alias-p 'mule-tests-alias-dos))) 216 (Assert (not (coding-system-alias-p 'mule-tests-alias-dos)))
217 (Assert (not (coding-system-alias-p 'mule-tests-alias-mac))) 217 (Assert (not (coding-system-alias-p 'mule-tests-alias-mac)))
218 218
219 (define-coding-system-alias 'mule-tests-alias (get-coding-system 'binary)) 219 (define-coding-system-alias 'mule-tests-alias (get-coding-system 'binary))
220 (Assert (coding-system-alias-p 'mule-tests-alias)) 220 (Assert (coding-system-alias-p 'mule-tests-alias))
221 (Assert (not (coding-system-canonical-name-p 'mule-tests-alias))) 221 (Assert (not (coding-system-canonical-name-p 'mule-tests-alias)))
222 (Assert (eq (get-coding-system 'binary) (get-coding-system 'mule-tests-alias))) 222 (Assert-eq (get-coding-system 'binary) (get-coding-system 'mule-tests-alias))
223 (Assert (eq 'binary (coding-system-aliasee 'mule-tests-alias))) 223 (Assert-eq 'binary (coding-system-aliasee 'mule-tests-alias))
224 (Assert (not (coding-system-alias-p 'mule-tests-alias-unix))) 224 (Assert (not (coding-system-alias-p 'mule-tests-alias-unix)))
225 (Assert (not (coding-system-alias-p 'mule-tests-alias-dos))) 225 (Assert (not (coding-system-alias-p 'mule-tests-alias-dos)))
226 (Assert (not (coding-system-alias-p 'mule-tests-alias-mac))) 226 (Assert (not (coding-system-alias-p 'mule-tests-alias-mac)))
227 227
228 (define-coding-system-alias 'nested-mule-tests-alias 'mule-tests-alias) 228 (define-coding-system-alias 'nested-mule-tests-alias 'mule-tests-alias)
229 (Assert (coding-system-alias-p 'nested-mule-tests-alias)) 229 (Assert (coding-system-alias-p 'nested-mule-tests-alias))
230 (Assert (not (coding-system-canonical-name-p 'nested-mule-tests-alias))) 230 (Assert (not (coding-system-canonical-name-p 'nested-mule-tests-alias)))
231 (Assert (eq (get-coding-system 'binary) (get-coding-system 'nested-mule-tests-alias))) 231 (Assert-eq (get-coding-system 'binary) (get-coding-system 'nested-mule-tests-alias))
232 (Assert (eq (coding-system-aliasee 'nested-mule-tests-alias) 'mule-tests-alias)) 232 (Assert-eq (coding-system-aliasee 'nested-mule-tests-alias) 'mule-tests-alias)
233 (Assert (eq 'mule-tests-alias (coding-system-aliasee 'nested-mule-tests-alias))) 233 (Assert-eq 'mule-tests-alias (coding-system-aliasee 'nested-mule-tests-alias))
234 (Assert (not (coding-system-alias-p 'nested-mule-tests-alias-unix))) 234 (Assert (not (coding-system-alias-p 'nested-mule-tests-alias-unix)))
235 (Assert (not (coding-system-alias-p 'nested-mule-tests-alias-dos))) 235 (Assert (not (coding-system-alias-p 'nested-mule-tests-alias-dos)))
236 (Assert (not (coding-system-alias-p 'nested-mule-tests-alias-mac))) 236 (Assert (not (coding-system-alias-p 'nested-mule-tests-alias-mac)))
237 237
238 (Check-Error-Message 238 (Check-Error-Message
264 264
265 ;; Create alias for coding system with subsidiaries 265 ;; Create alias for coding system with subsidiaries
266 (define-coding-system-alias 'mule-tests-alias 'iso-8859-7) 266 (define-coding-system-alias 'mule-tests-alias 'iso-8859-7)
267 (Assert (coding-system-alias-p 'mule-tests-alias)) 267 (Assert (coding-system-alias-p 'mule-tests-alias))
268 (Assert (not (coding-system-canonical-name-p 'mule-tests-alias))) 268 (Assert (not (coding-system-canonical-name-p 'mule-tests-alias)))
269 (Assert (eq (get-coding-system 'iso-8859-7) (get-coding-system 'mule-tests-alias))) 269 (Assert-eq (get-coding-system 'iso-8859-7) (get-coding-system 'mule-tests-alias))
270 (Assert (eq 'iso-8859-7 (coding-system-aliasee 'mule-tests-alias))) 270 (Assert-eq 'iso-8859-7 (coding-system-aliasee 'mule-tests-alias))
271 (Assert (coding-system-alias-p 'mule-tests-alias-unix)) 271 (Assert (coding-system-alias-p 'mule-tests-alias-unix))
272 (Assert (coding-system-alias-p 'mule-tests-alias-dos)) 272 (Assert (coding-system-alias-p 'mule-tests-alias-dos))
273 (Assert (coding-system-alias-p 'mule-tests-alias-mac)) 273 (Assert (coding-system-alias-p 'mule-tests-alias-mac))
274 274
275 (define-coding-system-alias 'mule-tests-alias (get-coding-system 'iso-8859-7)) 275 (define-coding-system-alias 'mule-tests-alias (get-coding-system 'iso-8859-7))
276 (Assert (coding-system-alias-p 'mule-tests-alias)) 276 (Assert (coding-system-alias-p 'mule-tests-alias))
277 (Assert (not (coding-system-canonical-name-p 'mule-tests-alias))) 277 (Assert (not (coding-system-canonical-name-p 'mule-tests-alias)))
278 (Assert (eq (get-coding-system 'iso-8859-7) (get-coding-system 'mule-tests-alias))) 278 (Assert-eq (get-coding-system 'iso-8859-7) (get-coding-system 'mule-tests-alias))
279 (Assert (eq 'iso-8859-7 (coding-system-aliasee 'mule-tests-alias))) 279 (Assert-eq 'iso-8859-7 (coding-system-aliasee 'mule-tests-alias))
280 (Assert (coding-system-alias-p 'mule-tests-alias-unix)) 280 (Assert (coding-system-alias-p 'mule-tests-alias-unix))
281 (Assert (coding-system-alias-p 'mule-tests-alias-dos)) 281 (Assert (coding-system-alias-p 'mule-tests-alias-dos))
282 (Assert (coding-system-alias-p 'mule-tests-alias-mac)) 282 (Assert (coding-system-alias-p 'mule-tests-alias-mac))
283 (Assert (eq (find-coding-system 'mule-tests-alias-mac) 283 (Assert-eq (find-coding-system 'mule-tests-alias-mac)
284 (find-coding-system 'iso-8859-7-mac))) 284 (find-coding-system 'iso-8859-7-mac))
285 285
286 (define-coding-system-alias 'nested-mule-tests-alias 'mule-tests-alias) 286 (define-coding-system-alias 'nested-mule-tests-alias 'mule-tests-alias)
287 (Assert (coding-system-alias-p 'nested-mule-tests-alias)) 287 (Assert (coding-system-alias-p 'nested-mule-tests-alias))
288 (Assert (not (coding-system-canonical-name-p 'nested-mule-tests-alias))) 288 (Assert (not (coding-system-canonical-name-p 'nested-mule-tests-alias)))
289 (Assert (eq (get-coding-system 'iso-8859-7) 289 (Assert-eq (get-coding-system 'iso-8859-7)
290 (get-coding-system 'nested-mule-tests-alias))) 290 (get-coding-system 'nested-mule-tests-alias))
291 (Assert (eq (coding-system-aliasee 'nested-mule-tests-alias) 'mule-tests-alias)) 291 (Assert-eq (coding-system-aliasee 'nested-mule-tests-alias) 'mule-tests-alias)
292 (Assert (eq 'mule-tests-alias (coding-system-aliasee 'nested-mule-tests-alias))) 292 (Assert-eq 'mule-tests-alias (coding-system-aliasee 'nested-mule-tests-alias))
293 (Assert (coding-system-alias-p 'nested-mule-tests-alias-unix)) 293 (Assert (coding-system-alias-p 'nested-mule-tests-alias-unix))
294 (Assert (coding-system-alias-p 'nested-mule-tests-alias-dos)) 294 (Assert (coding-system-alias-p 'nested-mule-tests-alias-dos))
295 (Assert (coding-system-alias-p 'nested-mule-tests-alias-mac)) 295 (Assert (coding-system-alias-p 'nested-mule-tests-alias-mac))
296 (Assert (eq (find-coding-system 'nested-mule-tests-alias-unix) 296 (Assert-eq (find-coding-system 'nested-mule-tests-alias-unix)
297 (find-coding-system 'iso-8859-7-unix))) 297 (find-coding-system 'iso-8859-7-unix))
298 298
299 (Check-Error-Message 299 (Check-Error-Message
300 error "Attempt to create a coding system alias loop" 300 error "Attempt to create a coding system alias loop"
301 (define-coding-system-alias 'mule-tests-alias 'nested-mule-tests-alias)) 301 (define-coding-system-alias 'mule-tests-alias 'nested-mule-tests-alias))
302 (Check-Error-Message 302 (Check-Error-Message
349 (let ((greek-string (charset-char-string 'greek-iso8859-7)) 349 (let ((greek-string (charset-char-string 'greek-iso8859-7))
350 (string (make-string (* 96 60) ??))) 350 (string (make-string (* 96 60) ??)))
351 (loop for j from 0 below (length string) do 351 (loop for j from 0 below (length string) do
352 (aset string j (aref greek-string (mod j 96)))) 352 (aset string j (aref greek-string (mod j 96))))
353 (loop for k in '(0 1 58 59) do 353 (loop for k in '(0 1 58 59) do
354 (Assert (equal (substring string (* 96 k) (* 96 (1+ k))) greek-string)))) 354 (Assert-equal (substring string (* 96 k) (* 96 (1+ k))) greek-string)))
355 355
356 (let ((greek-string (charset-char-string 'greek-iso8859-7)) 356 (let ((greek-string (charset-char-string 'greek-iso8859-7))
357 (string (make-string (* 96 60) ??))) 357 (string (make-string (* 96 60) ??)))
358 (loop for j from (1- (length string)) downto 0 do 358 (loop for j from (1- (length string)) downto 0 do
359 (aset string j (aref greek-string (mod j 96)))) 359 (aset string j (aref greek-string (mod j 96))))
360 (loop for k in '(0 1 58 59) do 360 (loop for k in '(0 1 58 59) do
361 (Assert (equal (substring string (* 96 k) (* 96 (1+ k))) greek-string)))) 361 (Assert-equal (substring string (* 96 k) (* 96 (1+ k))) greek-string)))
362 362
363 (let ((ascii-string (charset-char-string 'ascii)) 363 (let ((ascii-string (charset-char-string 'ascii))
364 (string (make-string (* 94 60) (make-char 'greek-iso8859-7 57)))) 364 (string (make-string (* 94 60) (make-char 'greek-iso8859-7 57))))
365 (loop for j from 0 below (length string) do 365 (loop for j from 0 below (length string) do
366 (aset string j (aref ascii-string (mod j 94)))) 366 (aset string j (aref ascii-string (mod j 94))))
367 (loop for k in '(0 1 58 59) do 367 (loop for k in '(0 1 58 59) do
368 (Assert (equal (substring string (* 94 k) (+ 94 (* 94 k))) ascii-string)))) 368 (Assert-equal (substring string (* 94 k) (+ 94 (* 94 k))) ascii-string)))
369 369
370 (let ((ascii-string (charset-char-string 'ascii)) 370 (let ((ascii-string (charset-char-string 'ascii))
371 (string (make-string (* 94 60) (make-char 'greek-iso8859-7 57)))) 371 (string (make-string (* 94 60) (make-char 'greek-iso8859-7 57))))
372 (loop for j from (1- (length string)) downto 0 do 372 (loop for j from (1- (length string)) downto 0 do
373 (aset string j (aref ascii-string (mod j 94)))) 373 (aset string j (aref ascii-string (mod j 94))))
374 (loop for k in '(0 1 58 59) do 374 (loop for k in '(0 1 58 59) do
375 (Assert (equal (substring string (* 94 k) (* 94 (1+ k))) ascii-string)))) 375 (Assert-equal (substring string (* 94 k) (* 94 (1+ k))) ascii-string)))
376 376
377 ;;--------------------------------------------------------------- 377 ;;---------------------------------------------------------------
378 ;; Test file-system character conversion (and, en passant, file ops) 378 ;; Test file-system character conversion (and, en passant, file ops)
379 ;;--------------------------------------------------------------- 379 ;;---------------------------------------------------------------
380 (let* ((dstroke (make-char 'latin-iso8859-2 80)) 380 (let* ((dstroke (make-char 'latin-iso8859-2 80))
413 ;; name3 already exists and OK-IF-ALREADY-EXISTS was not specified. 413 ;; name3 already exists and OK-IF-ALREADY-EXISTS was not specified.
414 (setq working-symlinks t))) 414 (setq working-symlinks t)))
415 (when working-symlinks 415 (when working-symlinks
416 (make-symbolic-link name1 name2) 416 (make-symbolic-link name1 name2)
417 (Assert (file-exists-p name2)) 417 (Assert (file-exists-p name2))
418 (Assert (equal (file-truename name2) name1)) 418 (Assert-equal (file-truename name2) name1)
419 (Assert (equal (file-truename name1) name1))) 419 (Assert-equal (file-truename name1) name1))
420 (ignore-file-errors (delete-file name1)) 420 (ignore-file-errors (delete-file name1))
421 (ignore-file-errors (delete-file name2)) 421 (ignore-file-errors (delete-file name2))
422 (ignore-file-errors (delete-file name3))) 422 (ignore-file-errors (delete-file name3)))
423 423
424 ;; Add many more file operation tests here... 424 ;; Add many more file operation tests here...
425 425
426 ;;--------------------------------------------------------------- 426 ;;---------------------------------------------------------------
427 ;; Test Unicode-related functions 427 ;; Test Unicode-related functions
428 ;;--------------------------------------------------------------- 428 ;;---------------------------------------------------------------
429 (let* ((scaron (make-char 'latin-iso8859-2 57))) 429 (let* ((scaron '(latin-iso8859-2 185)))
430 ;; Used to try #x0000, but you can't change ASCII or Latin-1 430 ;; Used to try #x0000, but you can't change ASCII or Latin-1
431 (loop 431 (loop
432 for code in '(#x0100 #x2222 #x4444 #xffff) 432 for code in '(#x0100 #x2222 #x4444 #xffff)
433 with initial-unicode = (char-to-unicode scaron) 433 with initial-unicode = (unicode-to-charset-codepoint
434 code '(latin-iso8859-2))
434 do 435 do
435 (progn 436 (progn
436 (set-unicode-conversion scaron code) 437 (apply 'set-unicode-conversion code scaron)
437 (Assert (eq code (char-to-unicode scaron))) 438 (Assert-eq code (apply 'charset-codepoint-to-unicode scaron))
438 (Assert (eq scaron (unicode-to-char code '(latin-iso8859-2))))) 439 (Assert-equal scaron (unicode-to-charset-codepoint
439 finally (set-unicode-conversion scaron initial-unicode)) 440 code '(latin-iso8859-2)))
440 (Check-Error wrong-type-argument (set-unicode-conversion scaron -10000))) 441 (apply 'set-unicode-conversion code initial-unicode)))
442 (Check-Error 'invalid-argument (apply 'set-unicode-conversion -10000
443 scaron)))
441 444
442 (dolist (utf-8-char 445 (dolist (utf-8-char
443 '("\xc6\x92" ;; U+0192 LATIN SMALL LETTER F WITH HOOK 446 '("\xc6\x92" ;; U+0192 LATIN SMALL LETTER F WITH HOOK
444 "\xe2\x81\x8a" ;; U+204A TIRONIAN SIGN ET 447 "\xe2\x81\x8a" ;; U+204A TIRONIAN SIGN ET
445 "\xe2\x82\xae" ;; U+20AE TUGRIK SIGN 448 "\xe2\x82\xae" ;; U+20AE TUGRIK SIGN
448 "\xf0\xaf\xa8\x88" ;; U+2FA08 CJK COMPATIBILITY FOR U+4BCE 451 "\xf0\xaf\xa8\x88" ;; U+2FA08 CJK COMPATIBILITY FOR U+4BCE
449 "\xf4\x8f\xbf\xbd")) ;; U+10FFFD <Plane 16 Private Use, Last> 452 "\xf4\x8f\xbf\xbd")) ;; U+10FFFD <Plane 16 Private Use, Last>
450 (let* ((xemacs-character (car (append 453 (let* ((xemacs-character (car (append
451 (decode-coding-string utf-8-char 'utf-8) 454 (decode-coding-string utf-8-char 'utf-8)
452 nil))) 455 nil)))
453 (xemacs-charset (car (split-char xemacs-character)))) 456 (xemacs-charset (char-charset xemacs-character)))
454 457
455 ;; Trivial test of the UTF-8 support of the escape-quoted character set. 458 ;; Trivial test of the UTF-8 support of the escape-quoted character set.
456 (Assert (equal (decode-coding-string utf-8-char 'utf-8) 459 (Assert-equal (decode-coding-string utf-8-char 'utf-8)
457 (decode-coding-string (concat "\033%G" utf-8-char) 460 (decode-coding-string (concat "\033%G" utf-8-char)
458 'escape-quoted))) 461 'escape-quoted))
459 462
460 ;; Check that the reverse mapping holds. 463 ;; Check that the reverse mapping holds.
461 (Assert (equal (unicode-code-point-to-utf-8-string 464 (Assert-equal (unicode-code-point-to-utf-8-string
462 (encode-char xemacs-character 'ucs)) 465 (encode-char xemacs-character 'ucs))
463 utf-8-char)) 466 utf-8-char)
464 467
465 ;; Check that, if this character has been JIT-allocated, it is encoded 468 ;; Check that, if this character has been JIT-allocated, it is encoded
466 ;; in escape-quoted using the corresponding UTF-8 escape. 469 ;; in escape-quoted using the corresponding UTF-8 escape.
467 (when (charset-property xemacs-charset 'encode-as-utf-8) 470 (when (charset-property xemacs-charset 'encode-as-utf-8)
468 (Assert (equal (concat "\033%G" utf-8-char) 471 (Assert-equal (concat "\033%G" utf-8-char)
469 (encode-coding-string xemacs-character 'escape-quoted))) 472 (encode-coding-string xemacs-character 'escape-quoted))
470 (Assert (equal (concat "\033%G" utf-8-char) 473 (Assert-equal (concat "\033%G" utf-8-char)
471 (encode-coding-string xemacs-character 'ctext)))))) 474 (encode-coding-string xemacs-character 'ctext)))))
472 475
473 (loop 476 (loop
474 for (code-point utf-16-big-endian utf-16-little-endian) 477 for (code-point utf-16-big-endian utf-16-little-endian)
475 in '((#x10000 "\xd8\x00\xdc\x00" "\x00\xd8\x00\xdc") 478 in '((#x10000 "\xd8\x00\xdc\x00" "\x00\xd8\x00\xdc")
476 (#x10FFFD "\xdb\xff\xdf\xfd" "\xff\xdb\xfd\xdf")) 479 (#x10FFFD "\xdb\xff\xdf\xfd" "\xff\xdb\xfd\xdf"))
477 do 480 do
478 (Assert (equal (encode-coding-string 481 (Assert-equal (encode-coding-string
479 (decode-char 'ucs code-point) 'utf-16) 482 (decode-char 'ucs code-point) 'utf-16)
480 utf-16-big-endian)) 483 utf-16-big-endian)
481 (Assert (equal (encode-coding-string 484 (Assert-equal (encode-coding-string
482 (decode-char 'ucs code-point) 'utf-16-le) 485 (decode-char 'ucs code-point) 'utf-16-le)
483 utf-16-little-endian))) 486 utf-16-little-endian))
484 487
485 488
486 ;;--------------------------------------------------------------- 489 ;;---------------------------------------------------------------
487 ;; Regression test for a couple of CCL-related bugs. 490 ;; Regression test for a couple of CCL-related bugs.
488 ;;--------------------------------------------------------------- 491 ;;---------------------------------------------------------------
495 (write-multibyte-character r0 r1) 498 (write-multibyte-character r0 r1)
496 (r1 = 31) 499 (r1 = 31)
497 (write-multibyte-character r0 r1))) 500 (write-multibyte-character r0 r1)))
498 "CCL program that writes two control-1 multibyte characters.") 501 "CCL program that writes two control-1 multibyte characters.")
499 502
500 (Assert (equal 503 (Assert-equal
501 (ccl-execute-on-string 'ccl-write-two-control-1-chars 504 (ccl-execute-on-string 'ccl-write-two-control-1-chars
502 ccl-vector "") 505 ccl-vector "")
503 (format "%c%c" (make-char 'control-1 0) 506 (format "%c%c" (make-char 'control-1 0)
504 (make-char 'control-1 31)))) 507 (make-char 'control-1 31)))
505 508
506 (define-ccl-program ccl-unicode-two-control-1-chars 509 (define-ccl-program ccl-unicode-two-control-1-chars
507 `(1 510 `(1
508 ((r0 = ,(charset-id 'control-1)) 511 ((r0 = ,(charset-id 'control-1))
509 (r1 = 31) 512 (r1 = 31)
537 (when (and (eq 'fixed-width (coding-system-type coding-system)) 540 (when (and (eq 'fixed-width (coding-system-type coding-system))
538 ;; Don't check the coding systems with odd line endings 541 ;; Don't check the coding systems with odd line endings
539 ;; (maybe we should): 542 ;; (maybe we should):
540 (eq 'lf (coding-system-eol-type coding-system))) 543 (eq 'lf (coding-system-eol-type coding-system)))
541 ;; These coding systems are round-trip compatible with themselves. 544 ;; These coding systems are round-trip compatible with themselves.
542 (Assert (equal (encode-coding-string 545 (Assert-equal (encode-coding-string
543 (decode-coding-string all-possible-octets 546 (decode-coding-string all-possible-octets
544 coding-system) 547 coding-system)
545 coding-system) 548 coding-system)
546 all-possible-octets) 549 all-possible-octets
547 (format "checking %s is transparent" coding-system)))) 550 (format "checking %s is transparent" coding-system))))
548 551
549 ;;--------------------------------------------------------------- 552 ;;---------------------------------------------------------------
550 ;; Test charset-in-* functions 553 ;; Test charset-in-* functions
551 ;;--------------------------------------------------------------- 554 ;;---------------------------------------------------------------
552 (with-temp-buffer 555 (with-temp-buffer
553 (insert-file-contents (locate-data-file "HELLO")) 556 (insert-file-contents (locate-data-file "HELLO"))
554 (Assert (equal 557 (Assert-equal
555 ;; The sort is to make the algorithm of charsets-in-region 558 ;; The sort is to make the algorithm of charsets-in-region
556 ;; irrelevant. 559 ;; irrelevant.
557 (sort (charsets-in-region (point-min) (point-max)) 560 (sort (charsets-in-region (point-min) (point-max))
558 #'string<) 561 #'string<)
559 '(ascii chinese-big5-1 chinese-gb2312 cyrillic-iso8859-5 562 '(ascii chinese-big5-1 chinese-gb2312 cyrillic-iso8859-5
560 ethiopic greek-iso8859-7 hebrew-iso8859-8 japanese-jisx0208 563 ethiopic greek-iso8859-7 hebrew-iso8859-8 japanese-jisx0208
561 japanese-jisx0212 jit-ucs-charset-0 katakana-jisx0201 564 japanese-jisx0212 jit-ucs-charset-0 katakana-jisx0201
562 korean-ksc5601 latin-iso8859-1 latin-iso8859-2 thai-xtis 565 korean-ksc5601 latin-iso8859-1 latin-iso8859-2 thai-xtis
563 vietnamese-viscii-lower))) 566 vietnamese-viscii-lower))
564 (Assert (equal 567 (Assert-equal
565 (sort (charsets-in-string (buffer-substring (point-min) 568 (sort (charsets-in-string (buffer-substring (point-min)
566 (point-max))) 569 (point-max)))
567 #'string<) 570 #'string<)
568 '(ascii chinese-big5-1 chinese-gb2312 cyrillic-iso8859-5 571 '(ascii chinese-big5-1 chinese-gb2312 cyrillic-iso8859-5
569 ethiopic greek-iso8859-7 hebrew-iso8859-8 japanese-jisx0208 572 ethiopic greek-iso8859-7 hebrew-iso8859-8 japanese-jisx0208
570 japanese-jisx0212 jit-ucs-charset-0 katakana-jisx0201 573 japanese-jisx0212 jit-ucs-charset-0 katakana-jisx0201
571 korean-ksc5601 latin-iso8859-1 latin-iso8859-2 thai-xtis 574 korean-ksc5601 latin-iso8859-1 latin-iso8859-2 thai-xtis
572 vietnamese-viscii-lower)))) 575 vietnamese-viscii-lower)))
573 576
574 ;;--------------------------------------------------------------- 577 ;;---------------------------------------------------------------
575 ;; Language environments, and whether the specified values are sane. 578 ;; Language environments, and whether the specified values are sane.
576 ;;--------------------------------------------------------------- 579 ;;---------------------------------------------------------------
577 (loop 580 (loop
580 with native-coding-system = nil 583 with native-coding-system = nil
581 with original-language-environment = current-language-environment 584 with original-language-environment = current-language-environment
582 do 585 do
583 ;; s-l-e can call #'require, which says "Loading ..." 586 ;; s-l-e can call #'require, which says "Loading ..."
584 (Silence-Message (set-language-environment language)) 587 (Silence-Message (set-language-environment language))
585 (Assert (equal language current-language-environment)) 588 (Assert-equal language current-language-environment)
586 589
587 (setq language-input-method 590 (setq language-input-method
588 (get-language-info language 'input-method)) 591 (get-language-info language 'input-method))
589 (when (and language-input-method 592 (when (and language-input-method
590 ;; #### Not robust, if more input methods besides canna are 593 ;; #### Not robust, if more input methods besides canna are
600 "input method unavailable" 603 "input method unavailable"
601 (format "check that IM %s can be activated" language-input-method) 604 (format "check that IM %s can be activated" language-input-method)
602 ;; s-i-m can load files. 605 ;; s-i-m can load files.
603 (Silence-Message 606 (Silence-Message
604 (set-input-method language-input-method)) 607 (set-input-method language-input-method))
605 (Assert (equal language-input-method current-input-method)))) 608 (Assert-equal language-input-method current-input-method)))
606 609
607 (dolist (charset (get-language-info language 'charset)) 610 (dolist (charset (get-language-info language 'charset))
608 (Assert (charsetp (find-charset charset)))) 611 (Assert (charsetp (find-charset charset))))
609 (dolist (coding-system (get-language-info language 'coding-system)) 612 (dolist (coding-system (get-language-info language 'coding-system))
610 (Assert (coding-system-p (find-coding-system coding-system)))) 613 (Assert (coding-system-p (find-coding-system coding-system))))