| ... | 
... | 
@@ -5,6 +5,12 @@ | 
| 
5
 | 
5
 | 
 
  | 
| 
6
 | 
6
 | 
 (in-package "ISSUES-TESTS")
  | 
| 
7
 | 
7
 | 
 
  | 
| 
 
 | 
8
 | 
+(defparameter *test-path*
  | 
| 
 
 | 
9
 | 
+  (merge-pathnames (make-pathname :name :unspecific :type :unspecific
  | 
| 
 
 | 
10
 | 
+                                  :version :unspecific)
  | 
| 
 
 | 
11
 | 
+                   *load-truename*)
  | 
| 
 
 | 
12
 | 
+  "Path to where this file is.")
  | 
| 
 
 | 
13
 | 
+
  | 
| 
8
 | 
14
 | 
 (defun square (x)
  | 
| 
9
 | 
15
 | 
   (expt x 2))
  | 
| 
10
 | 
16
 | 
 
  | 
| ... | 
... | 
@@ -676,4 +682,66 @@ | 
| 
676
 | 
682
 | 
   ;; work and not return NIL.
  | 
| 
677
 | 
683
 | 
   (assert-true (file-author "."))
  | 
| 
678
 | 
684
 | 
   (assert-true (file-author "bin/build.sh"))
  | 
| 
679
 | 
 
 | 
-  (assert-true (file-author "tests/안녕하십니까.txt")))  | 
| 
 
 | 
685
 | 
+  (let ((unix::*filename-encoding* :utf-8))
  | 
| 
 
 | 
686
 | 
+    ;; Set filename encoding to utf-8 so that we can encode the
  | 
| 
 
 | 
687
 | 
+    ;; filename properly.
  | 
| 
 
 | 
688
 | 
+    (assert-true
  | 
| 
 
 | 
689
 | 
+   (file-author
  | 
| 
 
 | 
690
 | 
+    (merge-pathnames 
  | 
| 
 
 | 
691
 | 
+     (concatenate 'string
  | 
| 
 
 | 
692
 | 
+		  ;; Write the test file name this way so
  | 
| 
 
 | 
693
 | 
+		  ;; that it's independent of the encoding
  | 
| 
 
 | 
694
 | 
+		  ;; used to load this file.  The name is
  | 
| 
 
 | 
695
 | 
+		  ;; "안녕하십니까".
  | 
| 
 
 | 
696
 | 
+		  '(#\Hangul_Syllable_An #\Hangul_Syllable_Nyeong #\Hangul_Syllable_Ha
  | 
| 
 
 | 
697
 | 
+		    #\Hangul_Syllable_Sib #\Hangul_Syllable_Ni #\Hangul_Syllable_Gga)
  | 
| 
 
 | 
698
 | 
+		  ".txt")
  | 
| 
 
 | 
699
 | 
+     *test-path*)))))
  | 
| 
 
 | 
700
 | 
+
  | 
| 
 
 | 
701
 | 
+(define-test issue.139-default-external-format
  | 
| 
 
 | 
702
 | 
+    (:tag :issues)
  | 
| 
 
 | 
703
 | 
+  (assert-eq :utf-8 stream:*default-external-format*))
  | 
| 
 
 | 
704
 | 
+
  | 
| 
 
 | 
705
 | 
+(define-test issue.139-default-external-format-read-file
  | 
| 
 
 | 
706
 | 
+    (:tag :issues)
  | 
| 
 
 | 
707
 | 
+  (let ((string (concatenate 'string
  | 
| 
 
 | 
708
 | 
+			     ;; This is "hello" in Korean
  | 
| 
 
 | 
709
 | 
+			     '(#\Hangul_syllable_an
  | 
| 
 
 | 
710
 | 
+			       #\Hangul_Syllable_Nyeong
  | 
| 
 
 | 
711
 | 
+			       #\Hangul_Syllable_Ha
  | 
| 
 
 | 
712
 | 
+			       #\Hangul_Syllable_Se
  | 
| 
 
 | 
713
 | 
+			       #\Hangul_Syllable_Yo))))
  | 
| 
 
 | 
714
 | 
+    ;; Test that opening a file for reading uses the the default :utf8
  | 
| 
 
 | 
715
 | 
+    ;; encoding.
  | 
| 
 
 | 
716
 | 
+    (with-open-file (s (merge-pathnames "utf8.txt"
  | 
| 
 
 | 
717
 | 
+					*test-path*)
  | 
| 
 
 | 
718
 | 
+		       :direction :input)
  | 
| 
 
 | 
719
 | 
+      ;; The first line should be "hello" in Hangul.
  | 
| 
 
 | 
720
 | 
+      (assert-equal (map 'list #'char-name string)
  | 
| 
 
 | 
721
 | 
+		    (map 'list #'char-name (read-line s))))))
  | 
| 
 
 | 
722
 | 
+
  | 
| 
 
 | 
723
 | 
+(define-test issue.139-default-external-format-write-file
  | 
| 
 
 | 
724
 | 
+    (:tag :issues)
  | 
| 
 
 | 
725
 | 
+  ;; Test that opening a file for writing uses the default :utf8.
  | 
| 
 
 | 
726
 | 
+  ;; First write something out to the file.  Then read it back in
  | 
| 
 
 | 
727
 | 
+  ;; using an explicit format of utf8 and verifying that we got the
  | 
| 
 
 | 
728
 | 
+  ;; right contents.
  | 
| 
 
 | 
729
 | 
+  (let ((string (concatenate 'string
  | 
| 
 
 | 
730
 | 
+			     ;; This is "hello" in Korean
  | 
| 
 
 | 
731
 | 
+			     '(#\Hangul_syllable_an
  | 
| 
 
 | 
732
 | 
+			       #\Hangul_Syllable_Nyeong
  | 
| 
 
 | 
733
 | 
+			       #\Hangul_Syllable_Ha
  | 
| 
 
 | 
734
 | 
+			       #\Hangul_Syllable_Se
  | 
| 
 
 | 
735
 | 
+			       #\Hangul_Syllable_Yo))))
  | 
| 
 
 | 
736
 | 
+    (with-open-file (s (merge-pathnames "out-utf8.txt"
  | 
| 
 
 | 
737
 | 
+					*test-path*)
  | 
| 
 
 | 
738
 | 
+		       :direction :output
  | 
| 
 
 | 
739
 | 
+		       :if-exists :supersede)
  | 
| 
 
 | 
740
 | 
+      (write-line string s))
  | 
| 
 
 | 
741
 | 
+    (with-open-file (s (merge-pathnames "out-utf8.txt"
  | 
| 
 
 | 
742
 | 
+					*test-path*)
  | 
| 
 
 | 
743
 | 
+		       :direction :input
  | 
| 
 
 | 
744
 | 
+		       :external-format :utf-8)
  | 
| 
 
 | 
745
 | 
+      (assert-equal (map 'list #'char-name string)
  | 
| 
 
 | 
746
 | 
+		    (map 'list #'char-name (read-line s))))))
  | 
| 
 
 | 
747
 | 
+    |