Check-in [7cb6f38f18]
Not logged in

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Merge 8.7
Timelines: family | ancestors | descendants | both | tip633-fconfigure-tolerantencoding
Files: files | file ages | folders
SHA3-256: 7cb6f38f18df6598c613259d62d18e1e283569f53fe188b1b709cbc685d3537f
User & Date: oehhar 2022-09-10 06:16:49.491
Context
2022-09-11
08:00
Merge 8.7 check-in: 978c3307c9 user: oehhar tags: tip633-fconfigure-tolerantencoding
2022-09-10
06:16
Merge 8.7 check-in: 7cb6f38f18 user: oehhar tags: tip633-fconfigure-tolerantencoding
06:07
Merge 8.6 check-in: b74cb0fee7 user: oehhar tags: core-8-branch
2022-09-09
17:09
TIP633: fconfigure -tolerantencoding: correct/add command interface tests check-in: ee91cf4d02 user: oehhar tags: tip633-fconfigure-tolerantencoding
Changes
Unified Diff Ignore Whitespace Patch
Changes to tests/io.test.
8948
8949
8950
8951
8952
8953
8954
8955
8956
8957
8958
8959
8960


8961
8962
8963
8964
8965
8966
8967
    read [teststringobj get 2]
} -cleanup {
    interp delete child
    testobj freeallvars
    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
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


	puts -nonewline $f "A\xC0\x40"
	flush $f
	seek $f 0
	fconfigure $f -encoding utf-8 -buffering none
} -body {
	read $f
} -cleanup {







|
|




>
>







8948
8949
8950
8951
8952
8953
8954
8955
8956
8957
8958
8959
8960
8961
8962
8963
8964
8965
8966
8967
8968
8969
    read [teststringobj get 2]
} -cleanup {
    interp delete child
    testobj freeallvars
    removeFile io-74.1
} -returnCodes error -match glob -result {can not find channel named "*"}

# 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
	fconfigure $f -encoding utf-8 -buffering none
} -body {
	read $f
} -cleanup {
8981
8982
8983
8984
8985
8986
8987



















8988
8989
8990
8991
8992
8993
8994
8995
8996
8997
8998
8999
9000
9001
9002
9003
9004
9005
9006
9007
9008
9009
9010
9011
9012
9013
	seek $f 0
	read $f
} -cleanup {
	close $f
	removeFile io-75.2
} -returnCodes ok -result "A?"




















test io-75.3 {check if -tolerantencoding option is saved} -setup {
	set fn [makeFile {} io-75.3]
    set f [open $fn w]
} -body {
	# the following command gets in result error in TCL 9.0
    fconfigure $f -encoding iso8859-1 -tolerantencoding 0
	lappend res [fconfigure $f -tolerantencoding]
    fconfigure $f -encoding iso8859-1 -tolerantencoding 1
	lappend res [fconfigure $f -tolerantencoding]
} -cleanup {
	close $f
	removeFile io-75.3
} -returnCodes ok -result "0 1"


# ### ### ### ######### ######### #########

# cleanup
foreach file [list fooBar longfile script script2 output test1 pipe my_script \
	test2 test3 cat stdout kyrillic.txt utf8-fcopy.txt utf8-rp.txt] {
    removeFile $file
}
cleanupTests
}
namespace delete ::tcl::test::io
return







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
|
|









|

<












8983
8984
8985
8986
8987
8988
8989
8990
8991
8992
8993
8994
8995
8996
8997
8998
8999
9000
9001
9002
9003
9004
9005
9006
9007
9008
9009
9010
9011
9012
9013
9014
9015
9016
9017
9018
9019
9020
9021

9022
9023
9024
9025
9026
9027
9028
9029
9030
9031
9032
9033
	seek $f 0
	read $f
} -cleanup {
	close $f
	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"

test io-75.4 {check if -tolerantencoding option is saved} -setup {
	set fn [makeFile {} io-75.4]
    set f [open $fn w]
} -body {
	# the following command gets in result error in TCL 9.0
    fconfigure $f -encoding iso8859-1 -tolerantencoding 0
	lappend res [fconfigure $f -tolerantencoding]
    fconfigure $f -encoding iso8859-1 -tolerantencoding 1
	lappend res [fconfigure $f -tolerantencoding]
} -cleanup {
	close $f
	removeFile io-75.4
} -returnCodes ok -result "0 1"


# ### ### ### ######### ######### #########

# cleanup
foreach file [list fooBar longfile script script2 output test1 pipe my_script \
	test2 test3 cat stdout kyrillic.txt utf8-fcopy.txt utf8-rp.txt] {
    removeFile $file
}
cleanupTests
}
namespace delete ::tcl::test::io
return