summaryrefslogtreecommitdiffstats
path: root/tests/io.test
diff options
context:
space:
mode:
authorpooryorick <com.digitalsmarties@pooryorick.com>2022-12-28 12:07:18 (GMT)
committerpooryorick <com.digitalsmarties@pooryorick.com>2022-12-28 12:07:18 (GMT)
commit4a8b2cf10f8ebcebaa9d3546f3399d3d9a8aa00e (patch)
treecc70e97f490ab84fa91b34aaa160f2e9d721d69b /tests/io.test
parentecaf98ffad23b0a547d0cedb852e0186d5c0c0af (diff)
downloadtcl-4a8b2cf10f8ebcebaa9d3546f3399d3d9a8aa00e.zip
tcl-4a8b2cf10f8ebcebaa9d3546f3399d3d9a8aa00e.tar.gz
tcl-4a8b2cf10f8ebcebaa9d3546f3399d3d9a8aa00e.tar.bz2
A better fix for [b8f575aa23], as it maintains the expectation that synchronous
[read] results in an error when invalid data is encountered. someone other than pooryorick: Pushed this check-in back on to a review branch. It needs more baking/review. As is, it makes two tests fail, and it introduces a new element "-result" to the return options dictionary.
Diffstat (limited to 'tests/io.test')
-rw-r--r--tests/io.test29
1 files changed, 16 insertions, 13 deletions
diff --git a/tests/io.test b/tests/io.test
index d10e1e4..451a790 100644
--- a/tests/io.test
+++ b/tests/io.test
@@ -9056,12 +9056,12 @@ test io-75.6 {invalid utf-8 encoding read is not ignored (-strictencoding 1)} -s
seek $f 0
fconfigure $f -encoding utf-8 -buffering none -eofchar "" -translation lf -strictencoding 1
} -body {
- set d [read $f]
+ set status [catch {read $f} cres copts]
+ set d [dict get $copts -result]
binary scan $d H* hd
- lappend hd [catch {read $f} msg]
- close $f
- lappend hd $msg
+ lappend hd $status $cres
} -cleanup {
+ close $f
removeFile io-75.6
} -match glob -result {41 1 {error reading "*": illegal byte sequence}}
@@ -9075,11 +9075,12 @@ test io-75.7 {invalid utf-8 encoding eof handling (-strictencoding 1)} -setup {
seek $f 0
fconfigure $f -encoding utf-8 -buffering none -eofchar \x1A -translation lf -strictencoding 1
} -body {
- set d [read $f]
+ set status [catch {read $f} cres copts]
+ set d [dict get $copts -result]
binary scan $d H* hd
lappend hd [eof $f]
- lappend hd [catch {read $f} msg]
- lappend hd $msg
+ lappend hd $status
+ lappend hd $cres
fconfigure $f -encoding iso8859-1
lappend hd [read $f];# We changed encoding, so now we can read the \xA1
close $f
@@ -9157,10 +9158,11 @@ test io-75.11 {shiftjis encoding error read results in raw bytes} -setup {
seek $f 0
fconfigure $f -encoding shiftjis -buffering none -eofchar "" -translation lf -strictencoding 1
} -body {
- set d [read $f]
+ set status [catch {read $f} cres copts]
+ set d [dict get $copts -result]
binary scan $d H* hd
- lappend hd [catch {set d [read $f]} msg]
- lappend hd $msg
+ lappend hd $status
+ lappend hd $cres
} -cleanup {
close $f
removeFile io-75.11
@@ -9192,11 +9194,12 @@ test io-75.13 {invalid utf-8 encoding read is not ignored (-strictencoding 1)} -
seek $f 0
fconfigure $f -encoding utf-8 -buffering none -eofchar "" -translation lf -strictencoding 1
} -body {
- set d [read $f]
+ set status [catch {read $f} cres copts]
+ set d [dict get $copts -result]
binary scan $d H* hd
- lappend hd [catch {read $f} msg]
+ lappend hd $status
close $f
- lappend hd $msg
+ lappend hd $cres
} -cleanup {
removeFile io-75.13
} -match glob -result {41 1 {error reading "*": illegal byte sequence}}