Diff
Not logged in

Differences From Artifact [9b8941d585]:

To Artifact [6e9d5d469e]:


8947
8948
8949
8950
8951
8952
8953

8954
8955
8956
8957
8958
8959
8960
8961
8962
8963
8964
8965
8966

8967
8968
8969
8970
8971
8972
8973
8974
8975
8976
8977
8978
8979
8980
    catch {read [teststringobj get 1]}
    read [teststringobj get 2]
} -cleanup {
    interp delete child
    testobj freeallvars
    removeFile io-74.1
} -returnCodes error -match glob -result {can not find channel named "*"}


test io-75.1 {multibyte encoding error read results in raw bytes (-strictencoding 0)} -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 -strictencoding 0 -buffering none
} -body {
	read $f

} -cleanup {
	close $f
	removeFile io-75.1
} -returnCodes ok -result "A\xC0\x40"
# for TCL 9.0, the result is error

test io-75.2 {unrepresentable character write passes and is replaced by ? (-strictencoding 0)} -constraints deprecated -setup {
	set fn [makeFile {} io-75.2]
    set f [open $fn w+]
    fconfigure $f -encoding iso8859-1 -strictencoding 0
} -body {
	# the following command gets in result error in TCL 9.0
	puts -nonewline $f "A\u2022"
	flush $f







>












|
>



|
<

|







8947
8948
8949
8950
8951
8952
8953
8954
8955
8956
8957
8958
8959
8960
8961
8962
8963
8964
8965
8966
8967
8968
8969
8970
8971
8972

8973
8974
8975
8976
8977
8978
8979
8980
8981
    catch {read [teststringobj get 1]}
    read [teststringobj get 2]
} -cleanup {
    interp delete child
    testobj freeallvars
    removeFile io-74.1
} -returnCodes error -match glob -result {can not find channel named "*"}


test io-75.1 {multibyte encoding error read results in raw bytes (-strictencoding 0)} -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 -strictencoding 0 -buffering none
} -body {
	set d [read $f]
	expr {$d eq "A\xC0\x40"}
} -cleanup {
	close $f
	removeFile io-75.1
} -returnCodes ok -result 1


test io-75.2 {unrepresentable character write passes and is replaced by ? (-strictencoding 0)} -setup {
	set fn [makeFile {} io-75.2]
    set f [open $fn w+]
    fconfigure $f -encoding iso8859-1 -strictencoding 0
} -body {
	# the following command gets in result error in TCL 9.0
	puts -nonewline $f "A\u2022"
	flush $f
9021
9022
9023
9024
9025
9026
9027
9028
9029
9030
9031
9032
9033
9034
9035
9036
9037
9038
9039
9040
9041
9042
9043
9044
9045
9046
9047
9048
9049
9050
9051
9052
9053
9054
9055
9056
9057
9058
9059
9060
9061
9062
9063
9064
9065
9066
9067
9068
9069
9070
9071
9072
9073
9074
9075
9076
9077
	removeFile io-75.4
} -returnCodes error

test io-75.5 {unrepresentable character write passes and is replaced by ? (-strictencoding 1} -setup {
	set fn [makeFile {} io-75.5]
    set f [open $fn w+]
    fconfigure $f -encoding iso8859-1
} -constraints knownBug -body {
	puts -nonewline $f "A\u2022"
} -cleanup {
	close $f
	removeFile io-75.5
} -returnCodes error

# Incomplete sequence test.
# This error may IMHO only be detected with the close.
# But the read already returns the incomplete sequence.
test io-75.6 {incomplete multibyte encoding read is ignored (-strictencoding 1)} -setup {
	set fn [makeFile {} io-75.6]
	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
} -constraints knownBug -body {
	set d [read $f]
	close $f
	set d
} -cleanup {
	removeFile io-75.5
} -returnCodes error

test io-75.7 {check if -tolerantencoding option is saved} -setup {
	set fn [makeFile {} io-75.7]
    set f [open $fn w]
} -body {
    fconfigure $f -encoding iso8859-1 -strictencoding 0
	lappend res [fconfigure $f -strictencoding]
    fconfigure $f -encoding iso8859-1 -strictencoding 1
	lappend res [fconfigure $f -strictencoding]
} -cleanup {
	close $f
	removeFile io-75.7
} -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







|

















|







<
<
<
<
<
<
<
<
<
<
<
<
<











9022
9023
9024
9025
9026
9027
9028
9029
9030
9031
9032
9033
9034
9035
9036
9037
9038
9039
9040
9041
9042
9043
9044
9045
9046
9047
9048
9049
9050
9051
9052
9053
9054













9055
9056
9057
9058
9059
9060
9061
9062
9063
9064
9065
	removeFile io-75.4
} -returnCodes error

test io-75.5 {unrepresentable character write passes and is replaced by ? (-strictencoding 1} -setup {
	set fn [makeFile {} io-75.5]
    set f [open $fn w+]
    fconfigure $f -encoding iso8859-1
} -body {
	puts -nonewline $f "A\u2022"
} -cleanup {
	close $f
	removeFile io-75.5
} -returnCodes error

# Incomplete sequence test.
# This error may IMHO only be detected with the close.
# But the read already returns the incomplete sequence.
test io-75.6 {incomplete multibyte encoding read is ignored (-strictencoding 1)} -setup {
	set fn [makeFile {} io-75.6]
	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.5
} -returnCodes error














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

# 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