diff options
author | jan.nijtmans <nijtmans@users.sourceforge.net> | 2023-11-13 20:24:45 (GMT) |
---|---|---|
committer | jan.nijtmans <nijtmans@users.sourceforge.net> | 2023-11-13 20:24:45 (GMT) |
commit | c12814c9d49023cf780dc0fc14cc749cd56e1d43 (patch) | |
tree | ed071c8a4fe241dc2ada388d8bf8d6d38506ba67 /tests/io.test | |
parent | 1c4be630c6908dac7103157d93ccacf1ffc299f4 (diff) | |
parent | f0c0a10b82a9a0f7e1ce7900fe6b8be3b6f88e55 (diff) | |
download | tcl-c12814c9d49023cf780dc0fc14cc749cd56e1d43.zip tcl-c12814c9d49023cf780dc0fc14cc749cd56e1d43.tar.gz tcl-c12814c9d49023cf780dc0fc14cc749cd56e1d43.tar.bz2 |
Merge 8.7
Diffstat (limited to 'tests/io.test')
-rw-r--r-- | tests/io.test | 84 |
1 files changed, 81 insertions, 3 deletions
diff --git a/tests/io.test b/tests/io.test index a427541..0737c2d 100644 --- a/tests/io.test +++ b/tests/io.test @@ -9193,7 +9193,7 @@ test io-75.5 {invalid utf-8 encoding read is ignored (-profile tcl8)} -setup { removeFile io-75.5 } -result 4181 -test io-75.6 {invalid utf-8 encoding, gets is not ignored (-profile strict)} -setup { +test io-75.6 {incomplete utf-8 encoding, blocking gets is not ignored (-profile strict)} -setup { set fn [makeFile {} io-75.6] set f [open $fn w+] fconfigure $f -encoding binary @@ -9211,6 +9211,84 @@ test io-75.6 {invalid utf-8 encoding, gets is not ignored (-profile strict)} -se } -match glob -returnCodes 1 -result {error reading "file*":\ invalid or incomplete multibyte or wide character} +test io-75.6.1 {invalid utf-8 encoding, blocking gets is not ignored (-profile strict)} -setup { + set fn [makeFile {} io-75.6.1] + set f [open $fn w+] + fconfigure $f -encoding binary + # utf-8: \xC3 requires a 2nd byte > x80, but <x80 is delivered + puts -nonewline $f A\xC3B + flush $f + seek $f 0 + fconfigure $f -encoding utf-8 -buffering none -eofchar {} \ + -translation lf -profile strict +} -body { + gets $f +} -cleanup { + close $f + removeFile io-75.6.1 +} -match glob -returnCodes 1 -result {error reading "file*":\ + invalid or incomplete multibyte or wide character} + +test io-75.6.2 {invalid utf-8 encoding, blocking gets is not ignored (-profile strict), recover functionality} -setup { + set fn [makeFile {} io-75.6.2] + set f [open $fn w+] + fconfigure $f -encoding binary + # utf-8: \xC3 requires a 2nd byte > x80, but <x80 is delivered + puts -nonewline $f A\xC3B + flush $f + seek $f 0 + fconfigure $f -encoding utf-8 -buffering none -eofchar {} \ + -translation lf -profile strict +} -body { + set l {} + lappend l [catch {gets $f}] + lappend l [tell $f] + fconfigure $f -encoding binary + lappend l [expr {[gets $f] eq "A\xC3B"}] +} -cleanup { + close $f + removeFile io-75.6.2 +} -match glob -returnCodes 0 -result {1 0 1} + +# TCL ticket c4eb46a196: non blocking case had endless loop, so test it +test io-75.6.3 {invalid utf-8 encoding, non blocking gets is not ignored (-profile strict)} -setup { + set fn [makeFile {} io-75.6.3] + set f [open $fn w+] + fconfigure $f -encoding binary + # utf-8: \xC3 requires a 2nd byte > x80, but <x80 is delivered + puts -nonewline $f A\xC3B + flush $f + seek $f 0 + fconfigure $f -encoding utf-8 -buffering none -eofchar {} \ + -translation lf -profile strict -blocking 0 +} -body { + gets $f +} -cleanup { + close $f + removeFile io-75.6.3 +} -match glob -returnCodes 1 -result {error reading "file*":\ + invalid or incomplete multibyte or wide character} + +test io-75.6.4 {incomplete utf-8 encoding, non blocking gets is not ignored (-profile strict)} -setup { + set fn [makeFile {} io-75.6.4] + set f [open $fn w+] + fconfigure $f -encoding binary + # \x81 is an incomplete byte sequence in utf-8 + puts -nonewline $f A\x81 + flush $f + seek $f 0 + fconfigure $f -encoding utf-8 -buffering none -eofchar {} \ + -translation lf -profile strict -blocking 0 +} -body { + gets $f + # only the 2nd gets returns the error + gets $f +} -cleanup { + close $f + removeFile io-75.6.4 +} -match glob -returnCodes 1 -result {error reading "file*":\ + invalid or incomplete multibyte or wide character} + test io-75.7 { invalid utf-8 encoding read is not ignored (-profile strict) } -setup { @@ -9232,7 +9310,7 @@ test io-75.7 { } -match glob -result {1 {error reading "file*":\ invalid or incomplete multibyte or wide character} A} -test io-75.8 {invalid utf-8 encoding eof handling (-profile strict)} -setup { +test io-75.8 {invalid utf-8 encoding eof first handling (-profile strict)} -setup { set fn [makeFile {} io-75.8] set f [open $fn w+] fconfigure $f -encoding binary @@ -9255,7 +9333,7 @@ test io-75.8 {invalid utf-8 encoding eof handling (-profile strict)} -setup { unset f d hd } -result {41 1 {}} -test io-75.8.eoflater {invalid utf-8 encoding eof handling (-profile strict)} -setup { +test io-75.8.eoflater {invalid utf-8 encoding eof after handling (-profile strict)} -setup { set fn [makeFile {} io-75.8] set f [open $fn w+] # This also configures the channel encoding profile as strict. |