diff options
author | jan.nijtmans <nijtmans@users.sourceforge.net> | 2020-12-01 15:15:28 (GMT) |
---|---|---|
committer | jan.nijtmans <nijtmans@users.sourceforge.net> | 2020-12-01 15:15:28 (GMT) |
commit | 5878b9510bf288f9e34e2bc65799101b209fec06 (patch) | |
tree | a5624132af562f3a5adf10a8346f9f9fd5a2fc55 | |
parent | 3ae4ed89d048fa82b852ea788b27088e72892efd (diff) | |
download | tcl-5878b9510bf288f9e34e2bc65799101b209fec06.zip tcl-5878b9510bf288f9e34e2bc65799101b209fec06.tar.gz tcl-5878b9510bf288f9e34e2bc65799101b209fec06.tar.bz2 |
Fix 2 testcases in Windows. Cause: tcltest::makeFile should assume the same encoding as the "source" command uses (TIP #589)
Aso remove the ::tcltest::bytestring command: It doesn't work any more starting Tcl 8.7 since the "identity" encoding is gone (TIP #345)
-rw-r--r-- | library/tcltest/tcltest.tcl | 16 | ||||
-rw-r--r-- | tests/encoding.test | 24 |
2 files changed, 25 insertions, 15 deletions
diff --git a/library/tcltest/tcltest.tcl b/library/tcltest/tcltest.tcl index 285a33d..32500c8 100644 --- a/library/tcltest/tcltest.tcl +++ b/library/tcltest/tcltest.tcl @@ -41,7 +41,9 @@ namespace eval tcltest { outputChannel testConstraint # Export commands that are duplication (candidates for deprecation) - namespace export bytestring ;# dups [encoding convertfrom identity] + if {![package vsatisfies [package provide Tcl] 8.7-]} { + namespace export bytestring ;# dups [encoding convertfrom identity] + } namespace export debug ;# [configure -debug] namespace export errorFile ;# [configure -errfile] namespace export limitConstraints ;# [configure -limitconstraints] @@ -3080,6 +3082,9 @@ proc tcltest::makeFile {contents name {directory ""}} { set fd [open $fullName w] chan configure $fd -translation lf + if {[package vsatisfies [package provide Tcl] 8.7-]} { + chan configure $fd -encoding utf-8 + } if {[string index $contents end] eq "\n"} { puts -nonewline $fd $contents } else { @@ -3249,6 +3254,9 @@ proc tcltest::viewFile {name {directory ""}} { # construct improperly formed strings in this manner, because it involves # exposing that Tcl uses UTF-8 internally. # +# This function doesn't work any more in Tcl 8.7, since the 'identity' +# is gone (TIP #345) +# # Arguments: # string being converted # @@ -3258,8 +3266,10 @@ proc tcltest::viewFile {name {directory ""}} { # Side effects: # None -proc tcltest::bytestring {string} { - return [encoding convertfrom identity $string] +if {![package vsatisfies [package provide Tcl] 8.7-]} { + proc tcltest::bytestring {string} { + return [encoding convertfrom identity $string] + } } # tcltest::OpenFiles -- diff --git a/tests/encoding.test b/tests/encoding.test index c0a3a69..362a611 100644 --- a/tests/encoding.test +++ b/tests/encoding.test @@ -535,17 +535,17 @@ test encoding-24.2 {EscapeFreeProc on open channels} {exec} { viewable [runInSubprocess { encoding system cp1252; # Bug #2891556 crash revelator fconfigure stdout -encoding iso2022-jp - puts ab乎\u68d9g + puts ab乎棙g set env(TCL_FINALIZE_ON_EXIT) 1 exit }] -} "ab\x1b\$B8C\x1b\$(DD%\x1b(Bg (ab\\u001b\$B8C\\u001b\$(DD%\\u001b(Bg)" +} "ab\x1B\$B8C\x1B\$(DD%\x1B(Bg (ab\\u001b\$B8C\\u001b\$(DD%\\u001b(Bg)" test encoding-24.3 {EscapeFreeProc on open channels} {stdio} { # Bug #219314 - if we don't free escape encodings correctly on channel # closure, we go boom set file [makeFile { encoding system iso2022-jp - set a "乎\u4e5e\u4e5f"; # 3 Japanese Kanji letters + set a "乎乞也"; # 3 Japanese Kanji letters puts $a } iso2022.tcl] set f [open "|[list [interpreter] $file]"] @@ -554,31 +554,31 @@ test encoding-24.3 {EscapeFreeProc on open channels} {stdio} { close $f removeFile iso2022.tcl list $count [viewable $line] -} [list 3 "乎\u4e5e\u4e5f (\\u4e4e\\u4e5e\\u4e5f)"] +} [list 3 "乎乞也 (\\u4e4e\\u4e5e\\u4e5f)"] test encoding-24.4 {Parse valid or invalid utf-8} { - string length [encoding convertfrom utf-8 "\xc0\x80"] + string length [encoding convertfrom utf-8 "\xC0\x80"] } 1 test encoding-24.5 {Parse valid or invalid utf-8} { - string length [encoding convertfrom utf-8 "\xc0\x81"] + string length [encoding convertfrom utf-8 "\xC0\x81"] } 2 test encoding-24.6 {Parse valid or invalid utf-8} { - string length [encoding convertfrom utf-8 "\xc1\xbf"] + string length [encoding convertfrom utf-8 "\xC1\xBF"] } 2 test encoding-24.7 {Parse valid or invalid utf-8} { - string length [encoding convertfrom utf-8 "\xc2\x80"] + string length [encoding convertfrom utf-8 "\xC2\x80"] } 1 test encoding-24.8 {Parse valid or invalid utf-8} { - string length [encoding convertfrom utf-8 "\xe0\x80\x80"] + string length [encoding convertfrom utf-8 "\xE0\x80\x80"] } 3 test encoding-24.9 {Parse valid or invalid utf-8} { - string length [encoding convertfrom utf-8 "\xe0\x9f\xbf"] + string length [encoding convertfrom utf-8 "\xE0\x9F\xBF"] } 3 test encoding-24.10 {Parse valid or invalid utf-8} { - string length [encoding convertfrom utf-8 "\xe0\xa0\x80"] + string length [encoding convertfrom utf-8 "\xE0\xA0\x80"] } 1 test encoding-24.11 {Parse valid or invalid utf-8} { - string length [encoding convertfrom utf-8 "\xef\xbf\xbf"] + string length [encoding convertfrom utf-8 "\xEF\xBF\xBF"] } 1 file delete [file join [temporaryDirectory] iso2022.txt] |