summaryrefslogtreecommitdiffstats
path: root/tests/io.test
diff options
context:
space:
mode:
authorpooryorick <com.digitalsmarties@pooryorick.com>2022-12-30 21:53:47 (GMT)
committerpooryorick <com.digitalsmarties@pooryorick.com>2022-12-30 21:53:47 (GMT)
commit3919b0a0b4e371b574d16adaa1c73df6da8007ce (patch)
tree798d88dc63400df275159e8f049c8dc47bdd4378 /tests/io.test
parent63e04b3c2dc7ecaf014a93f2116b5913a256e875 (diff)
downloadtcl-3919b0a0b4e371b574d16adaa1c73df6da8007ce.zip
tcl-3919b0a0b4e371b574d16adaa1c73df6da8007ce.tar.gz
tcl-3919b0a0b4e371b574d16adaa1c73df6da8007ce.tar.bz2
Add test for [gets] in non-strict mode after an encoding error.
Diffstat (limited to 'tests/io.test')
-rw-r--r--tests/io.test22
1 files changed, 22 insertions, 0 deletions
diff --git a/tests/io.test b/tests/io.test
index 6fb3587..2fa06ea 100644
--- a/tests/io.test
+++ b/tests/io.test
@@ -9254,6 +9254,28 @@ test io-75.13 {invalid utf-8 encoding read is not ignored (-strictencoding 1)} -
removeFile io-75.13
} -match glob -result {41 1 {error reading "*": illegal byte sequence}}
+test io-75.14 {invalid utf-8 encoding [gets] coninues in non-strict mode after error} -setup {
+ set fn [makeFile {} io-75.14]
+ set f [open $fn w+]
+ fconfigure $f -encoding binary
+ # \xc0 is invalid in utf-8
+ puts -nonewline $f a\nb\xc0\nc\n
+ flush $f
+ seek $f 0
+ fconfigure $f -encoding utf-8 -buffering none -eofchar {} -translation lf -strictencoding 1
+} -body {
+ lappend res [gets $f]
+ set status [catch {gets $f} cres copts]
+ lappend res $status $cres
+ chan configure $f -strictencoding 0
+ lappend res [gets $f]
+ lappend res [gets $f]
+ close $f
+ return $res
+} -cleanup {
+ removeFile io-75.14
+} -match glob -result {a 1 {error reading "*": illegal byte sequence} bÀ c}
+
# ### ### ### ######### ######### #########