summaryrefslogtreecommitdiffstats
path: root/tests/io.test
diff options
context:
space:
mode:
authorpooryorick <com.digitalsmarties@pooryorick.com>2023-04-03 20:58:46 (GMT)
committerpooryorick <com.digitalsmarties@pooryorick.com>2023-04-03 20:58:46 (GMT)
commit5d3ba90d87622e64517625053b18380f5dd96908 (patch)
tree2a3ed8e759765b838c6c58993d9c3f218a1d622a /tests/io.test
parent530c3b8f01ef15a975f0fc777f74e32bac90eae2 (diff)
downloadtcl-5d3ba90d87622e64517625053b18380f5dd96908.zip
tcl-5d3ba90d87622e64517625053b18380f5dd96908.tar.gz
tcl-5d3ba90d87622e64517625053b18380f5dd96908.tar.bz2
Fix for [fa3d9fd818fa0072], [fcopy $chan1 $chan2 -size $size] is not [puts
-nonewline $chan2 [read $chan1 -size $size].
Diffstat (limited to 'tests/io.test')
-rw-r--r--tests/io.test52
1 files changed, 38 insertions, 14 deletions
diff --git a/tests/io.test b/tests/io.test
index f7589ff..f235aff 100644
--- a/tests/io.test
+++ b/tests/io.test
@@ -7519,26 +7519,27 @@ test io-52.10 {TclCopyChannel & encodings} {fcopy} {
} 5
test io-52.11 {TclCopyChannel & encodings} -setup {
set out [open $path(utf8-fcopy.txt) w]
- fconfigure $out -encoding utf-8 -translation lf
- puts $out "АА"
+ fconfigure $out -encoding utf-8 -translation lf -profile strict
+ puts $out АА
close $out
} -constraints {fcopy} -body {
- # binary to encoding => the input has to be
- # in utf-8 to make sense to the encoder
-
set in [open $path(utf8-fcopy.txt) r]
set out [open $path(kyrillic.txt) w]
-
# -translation binary is also -encoding binary
fconfigure $in -translation binary
- fconfigure $out -encoding koi8-r -translation lf
-
- fcopy $in $out
- close $in
- close $out
-
- file size $path(kyrillic.txt)
-} -result 3
+ fconfigure $out -encoding koi8-r -translation lf -profile strict
+ catch {fcopy $in $out} cres copts
+ return $cres
+} -cleanup {
+ if {$in in [chan names]} {
+ close $in
+ }
+ if {$out in [chan names]} {
+ close $out
+ }
+ catch {unset cres}
+} -match glob -result {error writing "*": invalid or incomplete\
+ multibyte or wide character}
test io-52.12 {coverage of -translation auto} {
file delete $path(test1) $path(test2)
@@ -7780,6 +7781,29 @@ test io-52.23 {TclCopyChannel & encodings} -setup {
unset ::s0
} -match glob -result {0 {error writing "file*": invalid or incomplete multibyte or wide character}}
+test io-52.24 {fcopy -size should always be characters} -setup {
+ set out [open utf8-fcopy-52.24.txt w]
+ fconfigure $out -encoding utf-8 -translation lf
+ puts $out "Á"
+ close $out
+} -constraints {fcopy} -body {
+ set in [open utf8-fcopy-52.24.txt r]
+ set out [open utf8-fcopy-52.24.out.txt w+]
+
+ fconfigure $in -encoding utf-8 -profile tcl8
+ fconfigure $out -encoding utf-8 -profile tcl8
+ fcopy $in $out -size 1
+ seek $out 0
+ # a result of \xc3 means that only the first byte of the utf-8 encoding of
+ # Á made it into to the output file.
+ read $out
+} -cleanup {
+ close $in
+ close $out
+ catch {file delete utf8-fcopy-52.24.txt}
+ catch {file delete utf8-fcopy-52.24.out.txt}
+} -result Á
+
test io-53.1 {CopyData} {fcopy} {
file delete $path(test1)