comparison tests/automated/mule-tests.el @ 3948:adecfd791c9b

[xemacs-hg @ 2007-05-12 10:17:00 by aidan] Non-Latin-1 escapes can lead to corrupted ELC code.
author aidan
date Sat, 12 May 2007 10:17:09 +0000
parents cd487eafbc76
children 3584cb2c07db
comparison
equal deleted inserted replaced
3947:67e8a09db7ed 3948:adecfd791c9b
30 ;; Test some Mule functionality (most of these remain to be written) . 30 ;; Test some Mule functionality (most of these remain to be written) .
31 ;; See test-harness.el for instructions on how to run these tests. 31 ;; See test-harness.el for instructions on how to run these tests.
32 32
33 ;; This file will be (read)ed by a non-mule XEmacs, so don't use 33 ;; This file will be (read)ed by a non-mule XEmacs, so don't use
34 ;; literal non-Latin1 characters. Use (make-char) instead. 34 ;; literal non-Latin1 characters. Use (make-char) instead.
35
36 (require 'bytecomp)
35 37
36 ;;----------------------------------------------------------------- 38 ;;-----------------------------------------------------------------
37 ;; Test whether all legal chars may be safely inserted to a buffer. 39 ;; Test whether all legal chars may be safely inserted to a buffer.
38 ;;----------------------------------------------------------------- 40 ;;-----------------------------------------------------------------
39 41
463 '(arabic-1-column arabic-2-column ascii chinese-big5-1 465 '(arabic-1-column arabic-2-column ascii chinese-big5-1
464 chinese-gb2312 cyrillic-iso8859-5 ethiopic greek-iso8859-7 466 chinese-gb2312 cyrillic-iso8859-5 ethiopic greek-iso8859-7
465 hebrew-iso8859-8 japanese-jisx0208 japanese-jisx0212 467 hebrew-iso8859-8 japanese-jisx0208 japanese-jisx0212
466 katakana-jisx0201 korean-ksc5601 latin-iso8859-1 468 katakana-jisx0201 korean-ksc5601 latin-iso8859-1
467 latin-iso8859-2 thai-xtis vietnamese-viscii-lower)))) 469 latin-iso8859-2 thai-xtis vietnamese-viscii-lower))))
470
471 (with-temp-buffer
472 (flet
473 ((Assert-elc-is-escape-quoted ()
474 "Assert the current buffer has an escape-quoted cookie if compiled."
475 (save-excursion
476 (let ((byte-compile-result (byte-compile-from-buffer
477 (current-buffer) nil nil))
478 (temporary-file-name (make-temp-name
479 (expand-file-name "zjPQ2Pk"
480 (temp-directory)))))
481 (byte-compile-insert-header
482 temporary-file-name
483 (current-buffer)
484 byte-compile-result)
485 (Assert (string-match "^;;;###coding system: escape-quoted"
486 (buffer-substring nil nil
487 byte-compile-result))))))
488 (Assert-elc-has-no-specified-encoding ()
489 "Assert the current buffer has no coding cookie if compiled."
490 (save-excursion
491 (let ((byte-compile-result (byte-compile-from-buffer
492 (current-buffer) nil nil))
493 (temporary-file-name (make-temp-name
494 (expand-file-name "zjPQ2Pk"
495 (temp-directory)))))
496 (byte-compile-insert-header
497 temporary-file-name
498 (current-buffer)
499 byte-compile-result)
500 (Assert (not (string-match
501 ";;;###coding system:"
502 (buffer-substring nil nil byte-compile-result))))))))
503 (insert
504 ;; Create a buffer creating the Unicode escapes.
505 #r" (defvar testing-mule-compilation-handling
506 (string ?\u371E ;; kDefinition beautiful; pretty, used
507 ;; in girl's name
508 ?\U0002A6A9 ;; kDefinition (Cant.) sound of shouting
509 ?\U0002A65B ;; kDefinition (Cant.) decayed teeth;
510 ;; tongue-tied
511 ?\U00010400 ;; DESERET CAPITAL LETTER LONG I
512 ?\u3263)) ;; CIRCLED HANGUL RIEUL ")
513
514 (Assert-elc-is-escape-quoted)
515 (delete-region (point-min) (point-max))
516
517 (insert
518 ;; This time, the buffer will contain the actual characters, because of
519 ;; u flag to the #r.
520 #ru" (defvar testing-mule-compilation-handling
521 (string ?\u371E ;; kDefinition beautiful; pretty, used
522 ;; in girl's name
523 ?\U0002A6A9 ;; kDefinition (Cant.) sound of shouting
524 ?\U0002A65B ;; kDefinition (Cant.) decayed teeth;
525 ;; tongue-tied
526 ?\U00010400 ;; DESERET CAPITAL LETTER LONG I
527 ?\u3263)) ;; CIRCLED HANGUL RIEUL ")
528
529 (Assert-elc-is-escape-quoted)
530 (delete-region (point-min) (point-max))
531
532 (insert
533 ;; Just a single four character escape.
534 #r" (defvar testing-mule-compilation-handling
535 (string ?\u371E)) ;; kDefinition beautiful; pretty, used")
536
537 (Assert-elc-is-escape-quoted)
538 (delete-region (point-min) (point-max))
539
540 (insert
541 ;; Just a single eight character escape.
542 #r" (defvar testing-mule-compilation-handling
543 (string ?\U0002A65B)) ;; kDefinition (Cant.) decayed teeth;")
544
545 (Assert-elc-is-escape-quoted)
546 (delete-region (point-min) (point-max))
547
548 (insert
549 ;; A single latin-1 hex digit escape
550 #r" (defvar testing-mule-compilation-handling
551 (string ?\xab)) ;; LEFT-POINTING DOUBLE ANGLE QUOTATION MARK")
552
553 (Assert-elc-has-no-specified-encoding)
554 (delete-region (point-min) (point-max))
555
556 (insert
557 ;; A single latin-1 character
558 #ru" (defvar testing-mule-compilation-handling
559 (string ?\u00AB)) ;; LEFT-POINTING DOUBLE ANGLE QUOTATION MARK")
560
561 (Assert-elc-has-no-specified-encoding)
562 (delete-region (point-min) (point-max))
563
564 (insert
565 ;; Just ASCII.
566 #r" (defvar testing-mule-compilation-handling
567 (string ?A)) ;; LATIN CAPITAL LETTER A")
568
569 (Assert-elc-has-no-specified-encoding)
570 (delete-region (point-min) (point-max))))
468 ) 571 )