summaryrefslogtreecommitdiffstats
path: root/tests/io.test
diff options
context:
space:
mode:
authoroehhar <harald.oehlmann@elmicron.de>2022-09-10 06:07:18 (GMT)
committeroehhar <harald.oehlmann@elmicron.de>2022-09-10 06:07:18 (GMT)
commit36d126e09d78d8b823bc2df6013b4faa36b5f968 (patch)
tree61ffc6afc5afef35640d56b6d40f1ac9ea5a2992 /tests/io.test
parentfc474844a77a1f8a4fbde6335d9fe57e0166f7a3 (diff)
parentd894ead020bd4783df01cd4b5a0ac882dcae5d2f (diff)
downloadtcl-36d126e09d78d8b823bc2df6013b4faa36b5f968.zip
tcl-36d126e09d78d8b823bc2df6013b4faa36b5f968.tar.gz
tcl-36d126e09d78d8b823bc2df6013b4faa36b5f968.tar.bz2
Merge 8.6
Diffstat (limited to 'tests/io.test')
-rw-r--r--tests/io.test25
1 files changed, 23 insertions, 2 deletions
diff --git a/tests/io.test b/tests/io.test
index b6c4fb5..fd0c3ca 100644
--- a/tests/io.test
+++ b/tests/io.test
@@ -8952,12 +8952,14 @@ test io-74.1 {[104f2885bb] improper cache validity check} -setup {
removeFile io-74.1
} -returnCodes error -match glob -result {can not find channel named "*"}
-# Note: the following tests are in preparation for TCL 9.0, where those should
-# result in an error result
+# Note: the following tests 75.1 to 75.3 are in preparation for TCL 9.0, where
+# those should result in an error result
test io-75.1 {multibyte encoding error read results in raw bytes} -setup {
set fn [makeFile {} io-75.1]
set f [open $fn w+]
fconfigure $f -encoding binary
+ # In UTF-8, a byte 0xCx starts a multibyte sequence and must be followed
+ # by a byte > 0x7F. This is violated to get an invalid sequence.
puts -nonewline $f "A\xC0\x40"
flush $f
seek $f 0
@@ -8985,6 +8987,25 @@ test io-75.2 {unrepresentable character write passes and is replaced by ?} -setu
removeFile io-75.2
} -returnCodes ok -result "A?"
+# Incomplete sequence test.
+# This error may IMHO only be detected with the close.
+# But the read already returns the incomplete sequence.
+test io-75.3 {incomplete multibyte encoding read is ignored} -setup {
+ set fn [makeFile {} io-75.3]
+ set f [open $fn w+]
+ fconfigure $f -encoding binary
+ puts -nonewline $f "A\xC0"
+ flush $f
+ seek $f 0
+ fconfigure $f -encoding utf-8 -buffering none
+} -body {
+ set d [read $f]
+ close $f
+ set d
+} -cleanup {
+ removeFile io-75.3
+} -returnCodes ok -result "A\xC0"
+
# ### ### ### ######### ######### #########
# cleanup