Debian Codegraph @

ext/charconv/test.scm

raw
1 ;;
2 ;; test for charconv
3 ;;
4
5 (use gauche.test)
6
7 (test-start "charconv")
8 (use gauche.charconv)
9 (test-module 'gauche.charconv)
10
11 (define (file->string file)
12 (string-complete->incomplete
13 (call-with-input-file file port->byte-string)))
14
15 (define (file->string-conv/in file from . args)
16 (string-complete->incomplete
17 (call-with-input-file file
18 (lambda (f)
19 (port->byte-string (apply open-input-conversion-port f from args))))))
20
21 (define (file->string-conv/out file to from reader writer . args)
22 (string-complete->incomplete
23 (call-with-output-string
24 (lambda (out)
25 (call-with-input-file file
26 (lambda (in)
27 (let ((cv (apply open-output-conversion-port out to
28 :from-code from args)))
29 (let loop ((data (reader in)))
30 (if (eof-object? data)
31 (close-output-port cv)
32 (begin (writer data cv) (loop (reader in))))))))))))
33
34 (define (map-test tester file from-codes to-codes)
35 (let1 srcdir (sys-dirname (current-load-path))
36 (dolist [from from-codes]
37 (dolist [to to-codes]
38 (tester #"~|srcdir|/~|file|" from to)))))
39
40 ;;--------------------------------------------------------------------
41 (test-section "ces-equivalent? and ces-upper-compatible?")
42
43 (define-syntax ces=-test
44 (syntax-rules ()
45 ((_ op a b exp)
46 (test (format "~s ~s ~s" op a b) exp (lambda () (op a b '?))))))
47
48 (ces=-test ces-equivalent? 'none 'none #t)
49 (ces=-test ces-equivalent? 'eucjp 'euc-jp #t)
50 (ces=-test ces-equivalent? 'sjis 'shift_jis #t)
51 (ces=-test ces-equivalent? 'utf8 'utf-8 #t)
52 (ces=-test ces-equivalent? 'utf8 'none #t)
53 (ces=-test ces-equivalent? 'none 'eucjp #t)
54 (ces=-test ces-equivalent? 'sjis 'none #t)
55 (ces=-test ces-equivalent? 'eucjp "EUC-JP" #t)
56 (ces=-test ces-equivalent? "Shift_JIS" "SJIS" #t)
57 (ces=-test ces-equivalent? 'hoge 'euc-jp '?)
58 (ces=-test ces-equivalent? 'hoge 'none #t)
59
60 (ces=-test ces-upper-compatible? 'eucjp 'usascii #t)
61 (ces=-test ces-upper-compatible? 'usascii 'eucjp #f)
62 (ces=-test ces-upper-compatible? 'sjis 'usascii #t)
63 (ces=-test ces-upper-compatible? 'usascii 'sjis #f)
64 (ces=-test ces-upper-compatible? 'eucjp 'sjis #f)
65 (ces=-test ces-upper-compatible? 'sjis 'eucjp #f)
66 (ces=-test ces-upper-compatible? 'eucjp 'none #t)
67 (ces=-test ces-upper-compatible? 'none 'eucjp #t)
68 (ces=-test ces-upper-compatible? 'iso-2022-jp-2 'usascii #t)
69 (ces=-test ces-upper-compatible? 'usascii 'iso-2022-jp-2 #f)
70 (ces=-test ces-upper-compatible? 'iso-2022-jp-2 'iso-2022-jp #t)
71
72 ;;--------------------------------------------------------------------
73 (test-section "input conversion")
74
75 (define (test-input file from to :key (guesser #f) illegal-output)
76 (let* ((realfrom (or guesser from))
77 (infostr (format #f "~a.~a (~a) => ~a [~a]" file from realfrom to
78 illegal-output))
79 (fromfile (format #f "~a.~a" file from))
80 (tofile (format #f "~a.~a" file to)))
81 (if (ces-conversion-supported? from to)
82 (test infostr
83 (file->string tofile)
84 (lambda () (file->string-conv/in fromfile realfrom
85 :to-code to
86 :illegal-output illegal-output)))
87 (test infostr "(not supported)"
88 (lambda () "(not supported)")))
89 ))
90
91 (map-test test-input "data/jp1"
92 '("EUCJP" "UTF-8" "SJIS" "ISO2022JP" "UTF-16" "UTF-16BE" "UTF-16LE")
93 '("EUCJP" "UTF-8" "SJIS" "ISO2022JP" "UTF-16BE" "UTF-16LE"))
94 (map-test test-input "data/jp2"
95 '("EUCJP" "UTF-8" "SJIS" "ISO2022JP")
96 '("EUCJP" "UTF-8" "SJIS" "ISO2022JP"))
97 (map-test test-input "data/jp3"
98 '("EUCJP" "UTF-8" "SJIS" "ISO2022JP")
99 '("EUCJP" "UTF-8" "SJIS" "ISO2022JP"))
100 (map-test test-input "data/jp4"
101 '("EUCJP" "UTF-8" "SJIS" "ISO2022JP")
102 '("EUCJP" "UTF-8" "SJIS" "ISO2022JP"))
103 (map-test test-input "data/kr1"
104 '("EUCKR" "UTF-8" "ISO2022KR")
105 '("EUCKR" "UTF-8" "ISO2022KR"))
106
107 ;; illegal-output replace
108 (map-test (lambda (file from to)
109 (test-input file from to :illegal-output 'replace))
110 "data/jp1"
111 '("ASCII" "EUCJP" "UTF-8" "SJIS" "ISO2022JP")
112 '("ASCII"))
113 (map-test (lambda (file from to)
114 (test-input file from to :illegal-output 'replace))
115 "data/jp2"
116 '("EUCJP" "UTF-8" "SJIS" "ISO2022JP")
117 '("ASCII"))
118 (map-test (lambda (file from to)
119 (test-input file from to :illegal-output 'replace))
120 "data/lat1"
121 '("ISO8859-1")
122 '("ASCII" "ISO8859-1" "EUCJP" "SJIS" "ISO2022JP" "UTF-8"
123 "UTF-16" "UTF-16BE" "UTF-16LE"
124 "UTF-32" "UTF-32BE" "UTF-32LE"))
125 (map-test (lambda (file from to)
126 (test-input file from to :illegal-output 'replace))
127 "data/lat1x"
128 '("ISO8859-1" "EUCJP" "UTF-8" "SJIS"
129 "UTF-16" "UTF-16BE" "UTF-16LE"
130 "UTF-32" "UTF-32BE" "UTF-32LE")
131 '("ISO8859-1"))
132 (dolist [n '(2 3 4 5 6 7 8 9 10 11 13 14 15 16)]
133 (map-test test-input #"data/lat~|n|"
134 `(,#"ISO8859-~|n|" "UTF-16BE")
135 `(,#"ISO8859-~|n|" "UTF-16BE")))
136
137 ;; autodetect tester
138 (map-test (lambda (file from to)
139 (test-input file from to :guesser "*JP"))
140 "data/jp1"
141 '("EUCJP" "UTF-8" "SJIS" "ISO2022JP")
142 '("EUCJP" "UTF-8" "SJIS" "ISO2022JP"))
143 (map-test (lambda (file from to)
144 (test-input file from to :guesser "*JP"))
145 "data/jp2"
146 '("EUCJP" "UTF-8" "SJIS" "ISO2022JP")
147 '("EUCJP" "UTF-8" "SJIS" "ISO2022JP"))
148 (map-test (lambda (file from to)
149 (test-input file from to :guesser "*JP"))
150 "data/jp3"
151 '("EUCJP" "UTF-8" "SJIS" "ISO2022JP")
152 '("EUCJP" "UTF-8" "SJIS" "ISO2022JP"))
153
154 ;; UTF BOM illegal-output
155 (let ()
156 (define (f n) #"~(sys-dirname (current-load-path))/~n")
157
158 (define (bom-test bom-src)
159 (equal? (call-with-input-file (f "data/jp1.UTF-8") port->string)
160 (call-with-input-file (f bom-src) port->string)))
161 (bom-test "data/jp1.UTF-16-BOMBE")
162 (bom-test "data/jp1.UTF-16-BOMLE"))
163
164 ;;--------------------------------------------------------------------
165 (test-section "output conversion")
166
167 (define (test-output type reader writer file from to)
168 (let ((infostr (format #f "~a ~a => ~a (~a)" file from to type))
169 (fromfile (format #f "~a.~a" file from))
170 (tofile (format #f "~a.~a" file to)))
171 (if (ces-conversion-supported? from to)
172 (test infostr
173 (file->string tofile)
174 (lambda ()
175 (file->string-conv/out fromfile to from reader writer)))
176 (test infostr "(not supported)"
177 (lambda () "(not supported)")))
178 ))
179
180 (define (test-output/byte file from to)
181 (test-output "byte" read-byte write-byte file from to))
182
183 (define (test-output/char file from to)
184 (test-output "char" read-char write-char file from to))
185
186 (define (test-output/chunk256 file from to)
187 (test-output "chunk256" (^p (read-block 256 p)) display file from to))
188
189 (define (test-output/chunk20 file from to)
190 (test-output "chunk20" (^p (read-block 20 p)) display file from to))
191
192 (define internal-enc '("UTF-8"))
193
194 (map-test test-output/byte "data/jp1"
195 '("EUCJP" "UTF-8" "SJIS" "ISO2022JP" "UTF-16" "UTF-16BE" "UTF-16LE")
196 '("EUCJP" "UTF-8" "SJIS" "ISO2022JP" "UTF-16BE" "UTF-16LE"))
197 (map-test test-output/chunk256 "data/jp1"
198 '("EUCJP" "UTF-8" "SJIS" "ISO2022JP")
199 '("EUCJP" "UTF-8" "SJIS" "ISO2022JP"))
200 (map-test test-output/chunk20 "data/jp1"
201 '("EUCJP" "UTF-8" "SJIS" "ISO2022JP")
202 '("EUCJP" "UTF-8" "SJIS" "ISO2022JP"))
203 (map-test test-output/char "data/jp1"
204 internal-enc
205 '("EUCJP" "UTF-8" "SJIS" "ISO2022JP"))
206
207 (map-test test-output/byte "data/jp2"
208 '("EUCJP" "UTF-8" "SJIS" "ISO2022JP")
209 '("EUCJP" "UTF-8" "SJIS" "ISO2022JP"))
210 (map-test test-output/chunk256 "data/jp2"
211 '("EUCJP" "UTF-8" "SJIS" "ISO2022JP")
212 '("EUCJP" "UTF-8" "SJIS" "ISO2022JP"))
213 (map-test test-output/chunk20 "data/jp2"
214 '("EUCJP" "UTF-8" "SJIS" "ISO2022JP")
215 '("EUCJP" "UTF-8" "SJIS" "ISO2022JP"))
216 (map-test test-output/char "data/jp2"
217 internal-enc
218 '("EUCJP" "UTF-8" "SJIS" "ISO2022JP"))
219
220 (map-test test-output/byte "data/jp3"
221 '("EUCJP" "UTF-8" "SJIS" "ISO2022JP")
222 '("EUCJP" "UTF-8" "SJIS" "ISO2022JP"))
223 (map-test test-output/chunk256 "data/jp3"
224 '("EUCJP" "UTF-8" "SJIS" "ISO2022JP")
225 '("EUCJP" "UTF-8" "SJIS" "ISO2022JP"))
226 (map-test test-output/chunk20 "data/jp3"
227 '("EUCJP" "UTF-8" "SJIS" "ISO2022JP")
228 '("EUCJP" "UTF-8" "SJIS" "ISO2022JP"))
229 (map-test test-output/char "data/jp3"
230 internal-enc
231 '("EUCJP" "UTF-8" "SJIS" "ISO2022JP"))
232
233 (map-test test-output/byte "data/jp4"
234 '("EUCJP" "UTF-8" "SJIS" "ISO2022JP")
235 '("EUCJP" "UTF-8" "SJIS" "ISO2022JP"))
236 (map-test test-output/chunk256 "data/jp4"
237 '("EUCJP" "UTF-8" "SJIS" "ISO2022JP")
238 '("EUCJP" "UTF-8" "SJIS" "ISO2022JP"))
239 (map-test test-output/chunk20 "data/jp4"
240 '("EUCJP" "UTF-8" "SJIS" "ISO2022JP")
241 '("EUCJP" "UTF-8" "SJIS" "ISO2022JP"))
242 (map-test test-output/char "data/jp4"
243 internal-enc
244 '("EUCJP" "UTF-8" "SJIS" "ISO2022JP"))
245
246 (map-test test-output/byte "data/kr1"
247 '("EUCKR" "UTF-8" "ISO2022KR")
248 '("EUCKR" "UTF-8" "ISO2022KR"))
249 (map-test test-output/chunk256 "data/kr1"
250 '("EUCKR" "UTF-8" "ISO2022KR")
251 '("EUCKR" "UTF-8" "ISO2022KR"))
252 (map-test test-output/chunk20 "data/kr1"
253 '("EUCKR" "UTF-8" "ISO2022KR")
254 '("EUCKR" "UTF-8" "ISO2022KR"))
255
256 (dolist [n '(1 2 3 4 5 6 7 8 9 10 11 13 14 15 16)]
257 (map-test test-output/chunk20 #"data/lat~|n|"
258 `(,#"ISO8859-~|n|" "UTF-16BE")
259 `(,#"ISO8859-~|n|" "UTF-16BE")))
260
261 ;;--------------------------------------------------------------------
262 (test-section "open -> #f")
263
264 (test* "input :if-does-not-exist #f" #f
265 (with-input-from-file "_NOT_EXIST_" (lambda () (error "PANIC!"))
266 :if-does-not-exist #f :encoding "*JP"))
267
268 (test* "output :if-does-not-exist #f" #f
269 (with-output-to-file "_NOT_EXIST_" (lambda () (error "PANIC!"))
270 :if-does-not-exist #f :encoding "UTF-8"))
271
272 ;;--------------------------------------------------------------------
273 (test-section "utf8 optional BOM handling")
274
275 (let ()
276 (define (file->lines path encoding)
277 (call-with-input-file #"~(sys-dirname (current-load-path))/~path"
278 port->string-list
279 :encoding encoding))
280
281 (test* "utf8 optional BOM handling (utf8bom)"
282 '("abc" "\xfeff;def")
283 (file->lines "data/utf8bom.txt" 'utf-8-bom))
284
285 (test* "utf8 optional BOM handling (utf8)"
286 '("\xfeff;abc" "\xfeff;def")
287 (file->lines "data/utf8bom.txt" 'utf8))
288 )
289
290 ;;--------------------------------------------------------------------
291 (test-section "code guessing")
292
293 (define (test-guess file code scheme)
294 (let ((infostr (format #f "guess ~a from ~a.~a" scheme file code))
295 (infile (format #f "~a.~a" file code)))
296 ;; TODO: fix the kluge of CES name
297 (test infostr
298 (cond
299 ((string=? code "EUCJP") "EUC-JP")
300 ((string=? code "SJIS") "Shift_JIS")
301 ((string=? code "ISO2022JP") "ISO-2022-JP")
302 (else code))
303 (lambda ()
304 (ces-guess-from-string (file->string infile) scheme)))))
305
306 (map-test test-guess "data/jp1"
307 '("EUCJP" "UTF-8" "SJIS" "ISO2022JP")
308 '("*JP"))
309 (map-test test-guess "data/jp2"
310 '("EUCJP" "UTF-8" "SJIS" "ISO2022JP")
311 '("*JP"))
312 (map-test test-guess "data/jp3"
313 '("EUCJP" "UTF-8" "SJIS" "ISO2022JP")
314 '("*JP"))
315
316 ;;--------------------------------------------------------------------
317 (test-section "string conversion")
318
319 (define (test-string file from to)
320 (let ((infostr (format #f "string(~a) ~a => ~a" file from to))
321 (instr (file->string (format #f "~a.~a" file from)))
322 (outstr (file->string (format #f "~a.~a" file to))))
323 (if (ces-conversion-supported? from to)
324 (test infostr
325 outstr
326 (lambda ()
327 (string-complete->incomplete
328 (ces-convert instr from to))))
329 (test infostr "(not supported)"
330 (lambda () "(not supported)")))
331 ))
332
333 (map-test test-string "data/jp1"
334 '("EUCJP" "UTF-8" "SJIS" "ISO2022JP")
335 '("EUCJP" "UTF-8" "SJIS" "ISO2022JP"))
336 (map-test test-string "data/jp2"
337 '("EUCJP" "UTF-8" "SJIS" "ISO2022JP")
338 '("EUCJP" "UTF-8" "SJIS" "ISO2022JP"))
339 (map-test test-string "data/jp3"
340 '("EUCJP" "UTF-8" "SJIS" "ISO2022JP")
341 '("EUCJP" "UTF-8" "SJIS" "ISO2022JP"))
342 (map-test test-string "data/jp4"
343 '("EUCJP" "UTF-8" "SJIS" "ISO2022JP")
344 '("EUCJP" "UTF-8" "SJIS" "ISO2022JP"))
345
346 ;;-------------------------------------------------------------------
347 (test-section "replacement illegal-output")
348 (test* "utf-8 -> ascii noreplacement" (test-error <io-decoding-error>)
349 (ces-convert #u8(#x61 #xe3 #x81 #x82 #x62 #xe3 #x81
350 #x84 #x63 #xe3 #x81 #x86)
351 'utf-8 'ascii))
352 (test* "utf-8 -> ascii replacement" "a?b?c?"
353 (ces-convert #u8(#x61 #xe3 #x81 #x82 #x62 #xe3 #x81
354 #x84 #x63 #xe3 #x81 #x86)
355 'utf-8 'ascii :illegal-output 'replace))
356
357 (let ([src #u8(#x61 #xe2 #x98 #xba #x62 #xe2 #x9b #xb1 #x63)])
358 ;; src is #\a + snowman + #\b + umbrella + #\c
359 (test* "utf-8 -> eucjp noreplacement" (test-error <io-decoding-error>)
360 (ces-convert-to <u8vector> src 'utf-8 'eucjp))
361 (test* "utf-8 -> eucjp replacement" '#u8(#x61 #xa2 #xae #x62 #xa2 #xae #x63)
362 (ces-convert-to <u8vector> src 'utf-8 'eucjp :illegal-output 'replace))
363 (test* "utf-8 -> sjis noreplacement" (test-error <io-decoding-error>)
364 (ces-convert-to <u8vector> src 'utf-8 'sjis))
365 (test* "utf-8 -> sjis replacement" '#u8(#x61 #x81 #xac #x62 #x81 #xac #x63)
366 (ces-convert-to <u8vector> src 'utf-8 'sjis :illegal-output 'replace))
367 )
368
369 ;;--------------------------------------------------------------------
370 (test-section "wrapping conversion")
371
372 (define (test-wrap/in str from to)
373 (if (ces-conversion-supported? from to)
374 (test* #"wrap-input-conversion-port (~|from|, ~|to|)"
375 (string-complete->incomplete
376 (port->string (open-input-conversion-port
377 (open-input-string str)
378 from :to-code to :owner? #t)))
379 (string-complete->incomplete
380 (port->string (wrap-with-input-conversion
381 (open-input-string str)
382 from :to-code to))))
383 (test* #"wrap-input-conversion-port (~|from|, ~|to|)"
384 "(not supported)" "(not supported)")))
385
386 (define (test-wrap/out str from to)
387 (if (ces-conversion-supported? from to)
388 (test* #"wrap-output-conversion-port (~|from|, ~|to|)"
389 (string-complete->incomplete
390 (let* ((os (open-output-string))
391 (out (open-output-conversion-port os to :from-code from)))
392 (display str out)
393 (close-output-port out)
394 (get-output-string os)))
395 (string-complete->incomplete
396 (let* ((os (open-output-string))
397 (out (wrap-with-output-conversion os to :from-code from)))
398 (display str out)
399 (close-output-port out)
400 (get-output-string os))))
401 (test* #"wrap-input-conversion-port (~|from|, ~|to|)"
402 "(not supported)" "(not supported)")))
403
404 (map-test test-wrap/in "foobar"
405 '("NONE" "ASCII" "EUCJP" "UTF-8" "SJIS" "ISO2022JP")
406 '("NONE" "ASCII" "EUCJP" "UTF-8" "SJIS" "ISO2022JP"))
407 (map-test test-wrap/out "foobar"
408 '("NONE" "ASCII" "EUCJP" "UTF-8" "SJIS" "ISO2022JP")
409 '("NONE" "ASCII" "EUCJP" "UTF-8" "SJIS" "ISO2022JP"))
410
411 ;;--------------------------------------------------------------------
412 (test-section "call-with/conversion")
413
414 (define (test-call-with file code)
415 (if (ces-conversion-supported? code (gauche-character-encoding))
416 (test* #"call-with-input-conversion (~code -> ~(gauche-character-encoding))"
417 (file->string-conv/in #"~|file|.~code" code)
418 (string-complete->incomplete
419 (call-with-input-file #"~|file|.~code"
420 (lambda (p)
421 (call-with-input-conversion p port->string
422 :encoding code))))))
423 (if (ces-conversion-supported? (gauche-character-encoding) code)
424 (let ((s (call-with-input-file (format "~a.~a" file "UTF-8")
425 port->string)))
426 (test* #"call-with-output-conversion (~(gauche-character-encoding) -> ~code)"
427 (string-complete->incomplete
428 (ces-convert s (gauche-character-encoding) code))
429 (string-complete->incomplete
430 (call-with-output-string
431 (lambda (p)
432 (call-with-output-conversion p
433 (lambda (pp) (display s pp))
434 :encoding code)))))))
435 )
436
437 (dolist (file '("data/jp1" "data/jp2" "data/jp3" "data/jp4"))
438 (dolist (code '("EUCJP" "UTF-8" "SJIS" "ISO2022JP"))
439 (test-call-with #"~(sys-dirname (current-load-path))/~file" code)))
440
441 ;;--------------------------------------------------------------------
442 (test-section "ucs <-> char")
443
444 ;; this test is here since it requires gauche.charconv to be loaded.
445
446 (test "ucs <-> char" #x61
447 (lambda () (char->ucs (ucs->char #x61))))
448 (test "ucs <-> char" #xa1
449 (lambda () (char->ucs (ucs->char #xa1))))
450
451 (test "ucs <-> char" #x0391
452 (lambda () (char->ucs (ucs->char #x0391))))
453 (test "ucs <-> char" #x3042
454 (lambda () (char->ucs (ucs->char #x3042))))
455
456 (test "ucs char syntax" #\a
457 (lambda () (read-from-string "#\\u0061")))
458 (test "ucs char syntax" #\b
459 (lambda () (read-from-string "#\\u00000062")))
460 (test "ucs char syntax" #xa1
461 (lambda () (char->ucs (read-from-string "#\\u00a1"))))
462
463 (test "usc char syntax" #x0391
464 (lambda () (char->ucs (read-from-string "#\\u0391"))))
465 (test "ucs char syntax" #x3042
466 (lambda () (char->ucs (read-from-string "#\\u3042"))))
467
468 (test "ucs string syntax" "abcde"
469 (lambda () (read-from-string "\"\\u0061bcde\"")))
470 (test "ucs string syntax" "abcde"
471 (lambda () (read-from-string "\"\\U00000061bcde\"")))
472
473 (test "usc string syntax" #x0391
474 (lambda () (char->ucs (string-ref (read-from-string "\"\\u03911\"") 0))))
475 (test "ucs string syntax" #x3042
476 (lambda () (char->ucs (string-ref (read-from-string "\"\\u30421\"") 0))))
477
478 ;;--------------------------------------------------------------------
479 (test-section "coding-aware port")
480
481 (define *target-string*
482 (read-from-string
483 "\"\\u3053\\u3093\\u306b\\u3061\\u306f\\u3001\\u4e16\\u754c\""))
484
485 (define (test-coding-aware-port num encoding)
486 (when (ces-conversion-supported? (gauche-character-encoding) encoding)
487 (test* (format "program source port reading from jpsrc~a.~a" num encoding)
488 *target-string*
489 (call-with-input-file (format "~a/data/jpsrc~a.~a.scm"
490 (sys-dirname (current-load-path))
491 num encoding)
492 (lambda (in)
493 (let ((src (open-coding-aware-port in)))
494 (let loop ((x (read src)))
495 (cond ((eof-object? x) (close-input-port src) x)
496 ((eq? (cadr x) '*the-string*)
497 (close-input-port src)
498 (caddr x))
499 (else (loop (read src)))))))))))
500
501 (unless (eq? (gauche-character-encoding) 'none)
502 (dolist (num '(1 2 3))
503 (dolist (enc '("EUCJP" "SJIS" "UTF-8"))
504 (test-coding-aware-port num enc))))
505
506 ;;--------------------------------------------------------------------
507 (test-section "default-file-encoding")
508
509 (let1 srcdir (sys-dirname (current-load-path))
510 (test* "default-file-encoding (input)"
511 (call-with-input-file #"~|srcdir|/data/lat1.UTF-8" port->string)
512 (parameterize ([default-file-encoding 'latin1])
513 (call-with-input-file #"~|srcdir|/data/lat1.ISO8859-1" port->string)))
514 (sys-unlink "testdata.o")
515 (test* "default-file-encoding (output)"
516 (call-with-input-file #"~|srcdir|/data/lat1.ISO8859-1" port->byte-string)
517 (let1 data (call-with-input-file #"~|srcdir|/data/lat1.UTF-8" port->string)
518 (parameterize ([default-file-encoding 'latin1])
519 (call-with-output-file "testdata.o"
520 (^p (display data p))))
521 (call-with-input-file "testdata.o" port->byte-string)))
522 (sys-unlink "testdata.o"))
523
524 (test-end)