[Git][cmucl/cmucl][issue-139-default-external-format-utf8] Update release notes and add tests

Raymond Toy (@rtoy) gitlab at common-lisp.net
Sun Oct 30 16:14:18 UTC 2022



Raymond Toy pushed to branch issue-139-default-external-format-utf8 at cmucl / cmucl


Commits:
a130c526 by Raymond Toy at 2022-10-30T09:14:18-07:00
Update release notes and add tests

Update the release notes to say `*default-external-format*` is now
`:utf-8`.

Add tests for the default external format by opening files for reading
and writing and verifying that we get the right things with the
default format of :utf8.

Manually verified that these tests fail with version snapshot-2021-07.

- - - - -


2 changed files:

- src/general-info/release-21e.md
- tests/issues.lisp


Changes:

=====================================
src/general-info/release-21e.md
=====================================
@@ -22,6 +22,7 @@ public domain.
   * Feature enhancements
   * Changes
     * Update to ASDF 3.3.6
+    * The default external format is `:utf-8` instead of `:iso8859-1`
   * ANSI compliance fixes:
   * Bug fixes:
     * ~~#97~~ Fixes stepping through the source forms in the debugger.  This has been broken for quite some time, but it works now.
@@ -56,6 +57,7 @@ public domain.
     * ~~#132~~ Ansi test `RENAME-FILE.1` no fails
     * ~~#134~~ Handle the case of `(expt complex complex-rational)`
     * ~~#136~~ `ensure-directories-exist` should return the given pathspec
+    * #139 `*default-external-format*` defaults to `:utf-8`
     * ~~#142~~ `(random 0)` signals incorrect error
   * Other changes:
   * Improvements to the PCL implementation of CLOS:


=====================================
tests/issues.lisp
=====================================
@@ -5,6 +5,12 @@
 
 (in-package "ISSUES-TESTS")
 
+(defparameter *test-path*
+  (merge-pathnames (make-pathname :name :unspecific :type :unspecific
+                                  :version :unspecific)
+                   *load-truename*)
+  "Path to where this file is.")
+
 (defun square (x)
   (expt x 2))
 
@@ -670,3 +676,50 @@
 		 (err (relerr value answer)))
 	    (assert-true (<= err eps) base err eps)))))))
 
+(define-test issue.139-default-external-format
+    (:tag :issues)
+  (assert-eq :utf-8 stream:*default-external-format*))
+
+(define-test issue.139-default-external-format-read-file
+    (:tag :issues)
+  (let ((string (concatenate 'string
+			     ;; This is "hello" in Korean
+			     '(#\Hangul_syllable_an
+			       #\Hangul_Syllable_Nyeong
+			       #\Hangul_Syllable_Ha
+			       #\Hangul_Syllable_Se
+			       #\Hangul_Syllable_Yo))))
+    ;; Test that opening a file for reading uses the the default :utf8
+    ;; encoding.
+    (with-open-file (s (merge-pathnames "utf8.txt"
+					*test-path*)
+		       :direction :input)
+      ;; The first line should be "hello" in Hangul.
+      (assert-equal (map 'list #'char-name string)
+		    (map 'list #'char-name (read-line s))))))
+
+(define-test issue.139-default-external-format-write-file
+    (:tag :issues)
+  ;; Test that opening a file for writing uses the default :utf8.
+  ;; First write something out to the file.  Then read it back in
+  ;; using an explicit format of utf8 and verifying that we got the
+  ;; right contents.
+  (let ((string (concatenate 'string
+			     ;; This is "hello" in Korean
+			     '(#\Hangul_syllable_an
+			       #\Hangul_Syllable_Nyeong
+			       #\Hangul_Syllable_Ha
+			       #\Hangul_Syllable_Se
+			       #\Hangul_Syllable_Yo))))
+    (with-open-file (s (merge-pathnames "out-utf8.txt"
+					*test-path*)
+		       :direction :output
+		       :if-exists :supersede)
+      (write-line string s))
+    (with-open-file (s (merge-pathnames "out-utf8.txt"
+					*test-path*)
+		       :direction :input
+		       :external-format :utf-8)
+      (assert-equal (map 'list #'char-name string)
+		    (map 'list #'char-name (read-line s))))))
+  



View it on GitLab: https://gitlab.common-lisp.net/cmucl/cmucl/-/commit/a130c52629119ed282263fc86bf2254eb27ab702

-- 
View it on GitLab: https://gitlab.common-lisp.net/cmucl/cmucl/-/commit/a130c52629119ed282263fc86bf2254eb27ab702
You're receiving this email because of your account on gitlab.common-lisp.net.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mailman.common-lisp.net/pipermail/cmucl-cvs/attachments/20221030/c2f277f6/attachment-0001.html>


More information about the cmucl-cvs mailing list