diff options
author | oehhar <harald.oehlmann@elmicron.de> | 2023-11-20 13:55:31 (GMT) |
---|---|---|
committer | oehhar <harald.oehlmann@elmicron.de> | 2023-11-20 13:55:31 (GMT) |
commit | 23c8c9bc2cb4ac9d281ea38238932cfac707a27e (patch) | |
tree | 3959b5414136587cc07db9f893bed1610a9adfcb /tests/io.test | |
parent | edcc6e521c7581edaee0528ee5f7ec5975fe00a6 (diff) | |
parent | ee5350e804935ff2c79ed4d6f85a0b205e7a7915 (diff) | |
download | tcl-23c8c9bc2cb4ac9d281ea38238932cfac707a27e.zip tcl-23c8c9bc2cb4ac9d281ea38238932cfac707a27e.tar.gz tcl-23c8c9bc2cb4ac9d281ea38238932cfac707a27e.tar.bz2 |
Fix bug [a173f922]: fcopy does not write leading correct chars on later encoding error.
Diffstat (limited to 'tests/io.test')
-rw-r--r-- | tests/io.test | 53 |
1 files changed, 52 insertions, 1 deletions
diff --git a/tests/io.test b/tests/io.test index 5e650d5..8fb2a99 100644 --- a/tests/io.test +++ b/tests/io.test @@ -7719,6 +7719,28 @@ test io-52.20 {TclCopyChannel & encodings} -setup { close $out } -returnCodes 1 -match glob -result {error reading "file*": invalid or incomplete multibyte or wide character} +test io-52.20.2 {TclCopyChannel & encoding error on same encoding} -setup { + set out [open $path(utf8-fcopy.txt) w] + fconfigure $out -encoding utf-8 -translation lf + puts $out "AÁ" + 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 -profile strict + fconfigure $out -encoding ascii -translation lf + + fcopy $in $out +} -cleanup { + close $in + close $out +} -returnCodes 1 -match glob -result {error reading "file*": invalid or incomplete multibyte or wide character} + test io-52.21 {TclCopyChannel & encodings} -setup { set out [open $path(utf8-fcopy.txt) w] fconfigure $out -encoding utf-8 -translation lf @@ -7740,6 +7762,7 @@ test io-52.21 {TclCopyChannel & encodings} -setup { close $in close $out } -returnCodes 1 -match glob -result {error writing "file*": invalid or incomplete multibyte or wide character} + test io-52.22 {TclCopyChannel & encodings} -setup { set out [open $path(utf8-fcopy.txt) w] fconfigure $out -encoding utf-8 -translation lf @@ -7767,6 +7790,35 @@ test io-52.22 {TclCopyChannel & encodings} -setup { close $out unset ::s0 } -match glob -result {0 {error reading "file*": invalid or incomplete multibyte or wide character}} + +test io-52.22.1 {TclCopyChannel & encodings & tell position} -setup { + set out [open $path(utf8-fcopy.txt) w] + fconfigure $out -encoding utf-8 -translation lf + puts $out "AÁ" + 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 -profile strict + fconfigure $out -encoding koi8-r -translation lf + proc ::xxx args { + set ::s0 $args + } + + fcopy $in $out -command ::xxx + vwait ::s0 + list [tell $in] [tell $out] {*}[set ::s0] +} -cleanup { + close $in + close $out + unset ::s0 +} -match glob -result {1 1 1 {error reading "file*": invalid or incomplete multibyte or wide character}} + test io-52.23 {TclCopyChannel & encodings} -setup { set out [open $path(utf8-fcopy.txt) w] fconfigure $out -encoding utf-8 -translation lf @@ -7818,7 +7870,6 @@ test io-52.24 {fcopy -size should always be characters} -setup { catch {file delete utf8-fcopy-52.24.out.txt} } -result Á - test io-53.1 {CopyData} {fcopy} { file delete $path(test1) set f1 [open $thisScript] |