diff options
author | pooryorick <com.digitalsmarties@pooryorick.com> | 2023-04-03 20:58:46 (GMT) |
---|---|---|
committer | pooryorick <com.digitalsmarties@pooryorick.com> | 2023-04-03 20:58:46 (GMT) |
commit | 5d3ba90d87622e64517625053b18380f5dd96908 (patch) | |
tree | 2a3ed8e759765b838c6c58993d9c3f218a1d622a /tests | |
parent | 530c3b8f01ef15a975f0fc777f74e32bac90eae2 (diff) | |
download | tcl-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')
-rw-r--r-- | tests/chanio.test | 21 | ||||
-rw-r--r-- | tests/io.test | 52 |
2 files changed, 51 insertions, 22 deletions
diff --git a/tests/chanio.test b/tests/chanio.test index 09e71ca..ccef3e2 100644 --- a/tests/chanio.test +++ b/tests/chanio.test @@ -6886,18 +6886,23 @@ test chan-io-52.11 {TclCopyChannel & encodings} -setup { puts $f АА close $f } -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 chan configure $in -translation binary - chan configure $out -encoding koi8-r -translation lf - chan copy $in $out - chan close $in - chan close $out - file size $path(kyrillic.txt) -} -result 3 + chan configure $out -encoding koi8-r -translation lf -profile strict + catch {chan copy $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 chan-io-53.1 {CopyData} -setup { file delete $path(test1) 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) |