summaryrefslogtreecommitdiffstats
path: root/tests/io.test
diff options
context:
space:
mode:
authorapnadkarni <apnmbx-wits@yahoo.com>2023-02-15 05:24:48 (GMT)
committerapnadkarni <apnmbx-wits@yahoo.com>2023-02-15 05:24:48 (GMT)
commit6aed3e7d3039ffed6d02ae55fa06aa72550a93d2 (patch)
tree001bfa39d5075f2cc4567ccdc05702866ad19063 /tests/io.test
parent891d60a9ad2f9600dd9b1c3f0ce966d79a8942e8 (diff)
parent5040a69c28a92e0318ca56498bdf30f8690470ae (diff)
downloadtcl-6aed3e7d3039ffed6d02ae55fa06aa72550a93d2.zip
tcl-6aed3e7d3039ffed6d02ae55fa06aa72550a93d2.tar.gz
tcl-6aed3e7d3039ffed6d02ae55fa06aa72550a93d2.tar.bz2
Merge 8.7
Diffstat (limited to 'tests/io.test')
-rw-r--r--tests/io.test97
1 files changed, 97 insertions, 0 deletions
diff --git a/tests/io.test b/tests/io.test
index b748aeb..0f47a8e 100644
--- a/tests/io.test
+++ b/tests/io.test
@@ -7643,6 +7643,103 @@ test io-52.19 {coverage of eofChar handling} {
close $out
file size $path(test2)
} 8
+test io-52.20 {TclCopyChannel & encodings} -setup {
+ set out [open $path(utf8-fcopy.txt) w]
+ fconfigure $out -encoding utf-8 -translation lf
+ 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]
+
+ # Using "-encoding ascii" means reading the "Á" gives an error
+ fconfigure $in -encoding ascii -encodingprofile strict
+ fconfigure $out -encoding koi8-r -translation lf
+
+ fcopy $in $out
+} -cleanup {
+ close $in
+ close $out
+} -returnCodes 1 -match glob -result {error reading "file*": illegal byte sequence}
+test io-52.21 {TclCopyChannel & encodings} -setup {
+ set out [open $path(utf8-fcopy.txt) w]
+ fconfigure $out -encoding utf-8 -translation lf
+ 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]
+
+ # Using "-encoding ascii" means writing the "Á" gives an error
+ fconfigure $in -encoding utf-8
+ fconfigure $out -encoding ascii -translation lf -encodingprofile strict
+
+ fcopy $in $out
+} -cleanup {
+ close $in
+ close $out
+} -returnCodes 1 -match glob -result {error writing "file*": illegal byte sequence}
+test io-52.22 {TclCopyChannel & encodings} -setup {
+ set out [open $path(utf8-fcopy.txt) w]
+ fconfigure $out -encoding utf-8 -translation lf
+ 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]
+
+ # Using "-encoding ascii" means reading the "Á" gives an error
+ fconfigure $in -encoding ascii -encodingprofile strict
+ fconfigure $out -encoding koi8-r -translation lf
+ proc ::xxx args {
+ set ::s0 $args
+ }
+
+ fcopy $in $out -command ::xxx
+ vwait ::s0
+ set ::s0
+} -cleanup {
+ close $in
+ close $out
+ unset ::s0
+} -match glob -result {0 {error reading "file*": illegal byte sequence}}
+test io-52.23 {TclCopyChannel & encodings} -setup {
+ set out [open $path(utf8-fcopy.txt) w]
+ fconfigure $out -encoding utf-8 -translation lf
+ 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]
+
+ # Using "-encoding ascii" means writing the "Á" gives an error
+ fconfigure $in -encoding utf-8
+ fconfigure $out -encoding ascii -translation lf -encodingprofile strict
+ proc ::xxx args {
+ set ::s0 $args
+ }
+
+ fcopy $in $out -command ::xxx
+ vwait ::s0
+ set ::s0
+} -cleanup {
+ close $in
+ close $out
+ unset ::s0
+} -match glob -result {0 {error writing "file*": illegal byte sequence}}
+
test io-53.1 {CopyData} {fcopy} {
file delete $path(test1)