summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorjan.nijtmans <nijtmans@users.sourceforge.net>2023-01-27 14:23:08 (GMT)
committerjan.nijtmans <nijtmans@users.sourceforge.net>2023-01-27 14:23:08 (GMT)
commit06de3a9ba1e4397a226e168a72c9da63c2a6f30a (patch)
treee17a3e1a21528a5c712eee242718cf57648f9576 /tests
parent46dcc60e4182a6b1bfae4b7bf93d03430e5e8ce6 (diff)
downloadtcl-06de3a9ba1e4397a226e168a72c9da63c2a6f30a.zip
tcl-06de3a9ba1e4397a226e168a72c9da63c2a6f30a.tar.gz
tcl-06de3a9ba1e4397a226e168a72c9da63c2a6f30a.tar.bz2
new testcase encoding-18.1. Testcase cleanup
Diffstat (limited to 'tests')
-rw-r--r--tests/encoding.test151
1 files changed, 76 insertions, 75 deletions
diff --git a/tests/encoding.test b/tests/encoding.test
index aaba01e..f558e01 100644
--- a/tests/encoding.test
+++ b/tests/encoding.test
@@ -3,7 +3,7 @@
# No output means no errors were found.
#
# Copyright (c) 1997 Sun Microsystems, Inc.
-# Copyright (c) 1998-1999 by Scriptics Corporation.
+# Copyright (c) 1998-1999 Scriptics Corporation.
#
# See the file "license.terms" for information on usage and redistribution of
# this file, and for a DISCLAIMER OF ALL WARRANTIES.
@@ -65,12 +65,12 @@ test encoding-1.2 {Tcl_GetEncoding: existing encoding} {testencoding} {
return $x
} {{fromutf }}
test encoding-1.3 {Tcl_GetEncoding: load encoding} {
- list [encoding convertto jis0208 \u4e4e] \
+ list [encoding convertto jis0208 \u4E4E] \
[encoding convertfrom jis0208 8C]
-} "8C \u4e4e"
+} "8C \u4E4E"
test encoding-2.1 {Tcl_FreeEncoding: refcount == 0} {
- encoding convertto jis0208 \u4e4e
+ encoding convertto jis0208 \u4E4E
} {8C}
test encoding-2.2 {Tcl_FreeEncoding: refcount != 0} -setup {
set system [encoding system]
@@ -78,15 +78,15 @@ test encoding-2.2 {Tcl_FreeEncoding: refcount != 0} -setup {
} -constraints {testencoding} -body {
encoding system shiftjis ;# incr ref count
encoding dirs [list [pwd]]
- set x [encoding convertto shiftjis \u4e4e] ;# old one found
+ set x [encoding convertto shiftjis \u4E4E] ;# old one found
encoding system iso8859-1
llength shiftjis ;# Shimmer away any cache of Tcl_Encoding
- lappend x [catch {encoding convertto shiftjis \u4e4e} msg] $msg
+ lappend x [catch {encoding convertto shiftjis \u4E4E} msg] $msg
} -cleanup {
encoding system iso8859-1
encoding dirs $path
encoding system $system
-} -result "\u008c\u00c1 1 {unknown encoding \"shiftjis\"}"
+} -result "\x8C\xC1 1 {unknown encoding \"shiftjis\"}"
test encoding-3.1 {Tcl_GetEncodingName, NULL} -setup {
set old [encoding system]
@@ -138,7 +138,7 @@ test encoding-5.1 {Tcl_SetSystemEncoding} -setup {
set old [encoding system]
} -body {
encoding system jis0208
- encoding convertto \u4e4e
+ encoding convertto \u4E4E
} -cleanup {
encoding system iso8859-1
encoding system $old
@@ -170,7 +170,7 @@ test encoding-6.2 {Tcl_CreateEncoding: replace encoding} {testencoding} {
test encoding-7.1 {Tcl_ExternalToUtfDString: small buffer} {
encoding convertfrom jis0208 8c8c8c8c
-} "\u543e\u543e\u543e\u543e"
+} "\u543E\u543E\u543E\u543E"
test encoding-7.2 {Tcl_UtfToExternalDString: big buffer} {
set a 8C8C8C8C8C8C8C8C8C8C8C8C8C8C8C8C8C8C8C8C8C8C8C8C8C8C8C8C8C8C8C8C
append a $a
@@ -179,12 +179,12 @@ test encoding-7.2 {Tcl_UtfToExternalDString: big buffer} {
append a $a
set x [encoding convertfrom jis0208 $a]
list [string length $x] [string index $x 0]
-} "512 \u4e4e"
+} "512 \u4E4E"
test encoding-8.1 {Tcl_ExternalToUtf} {
set f [open [file join [temporaryDirectory] dummy] w]
fconfigure $f -translation binary -encoding iso8859-1
- puts -nonewline $f "ab\x8c\xc1g"
+ puts -nonewline $f "ab\x8C\xC1g"
close $f
set f [open [file join [temporaryDirectory] dummy] r]
fconfigure $f -translation binary -encoding shiftjis
@@ -192,13 +192,13 @@ test encoding-8.1 {Tcl_ExternalToUtf} {
close $f
file delete [file join [temporaryDirectory] dummy]
return $x
-} "ab\u4e4eg"
+} "ab\u4E4Eg"
test encoding-9.1 {Tcl_UtfToExternalDString: small buffer} {
- encoding convertto jis0208 "\u543e\u543e\u543e\u543e"
+ encoding convertto jis0208 "\u543E\u543E\u543E\u543E"
} {8c8c8c8c}
test encoding-9.2 {Tcl_UtfToExternalDString: big buffer} {
- set a \u4e4e\u4e4e\u4e4e\u4e4e\u4e4e\u4e4e\u4e4e\u4e4e
+ set a \u4E4E\u4E4E\u4E4E\u4E4E\u4E4E\u4E4E\u4E4E\u4E4E
append a $a
append a $a
append a $a
@@ -212,7 +212,7 @@ test encoding-9.2 {Tcl_UtfToExternalDString: big buffer} {
test encoding-10.1 {Tcl_UtfToExternal} {
set f [open [file join [temporaryDirectory] dummy] w]
fconfigure $f -translation binary -encoding shiftjis
- puts -nonewline $f "ab\u4e4eg"
+ puts -nonewline $f "ab\u4E4Eg"
close $f
set f [open [file join [temporaryDirectory] dummy] r]
fconfigure $f -translation binary -encoding iso8859-1
@@ -220,7 +220,7 @@ test encoding-10.1 {Tcl_UtfToExternal} {
close $f
file delete [file join [temporaryDirectory] dummy]
return $x
-} "ab\x8c\xc1g"
+} "ab\x8C\xC1g"
proc viewable {str} {
set res ""
@@ -228,7 +228,7 @@ proc viewable {str} {
if {[string is print $c] && [string is ascii $c]} {
append res $c
} else {
- append res "\\u[format %4.4x [scan $c %c]]"
+ append res "\\u[format %4.4X [scan $c %c]]"
}
}
return "$str ($res)"
@@ -240,26 +240,26 @@ test encoding-11.1 {LoadEncodingFile: unknown encoding} {testencoding} {
encoding system iso8859-1
encoding dirs {}
llength jis0208 ;# Shimmer any cached Tcl_Encoding in shared literal
- set x [list [catch {encoding convertto jis0208 \u4e4e} msg] $msg]
+ set x [list [catch {encoding convertto jis0208 \u4E4E} msg] $msg]
encoding dirs $path
encoding system $system
- lappend x [encoding convertto jis0208 \u4e4e]
+ lappend x [encoding convertto jis0208 \u4E4E]
} {1 {unknown encoding "jis0208"} 8C}
test encoding-11.2 {LoadEncodingFile: single-byte} {
- encoding convertfrom jis0201 \xa1
-} "\uff61"
+ encoding convertfrom jis0201 \xA1
+} \uFF61
test encoding-11.3 {LoadEncodingFile: double-byte} {
encoding convertfrom jis0208 8C
-} "\u4e4e"
+} \u4E4E
test encoding-11.4 {LoadEncodingFile: multi-byte} {
- encoding convertfrom shiftjis \x8c\xc1
-} "\u4e4e"
+ encoding convertfrom shiftjis \x8C\xC1
+} \u4E4E
test encoding-11.5 {LoadEncodingFile: escape file} {
- viewable [encoding convertto iso2022 \u4e4e]
-} [viewable "\x1b\$B8C\x1b(B"]
+ viewable [encoding convertto iso2022 \u4E4E]
+} [viewable "\x1B\$B8C\x1B(B"]
test encoding-11.5.1 {LoadEncodingFile: escape file} {
- viewable [encoding convertto iso2022-jp \u4e4e]
-} [viewable "\x1b\$B8C\x1b(B"]
+ viewable [encoding convertto iso2022-jp \u4E4E]
+} [viewable "\x1B\$B8C\x1B(B"]
test encoding-11.6 {LoadEncodingFile: invalid file} -constraints {testencoding} -setup {
set system [encoding system]
set path [encoding dirs]
@@ -273,7 +273,7 @@ test encoding-11.6 {LoadEncodingFile: invalid file} -constraints {testencoding}
fconfigure $f -translation binary
puts $f "abcdefghijklmnop"
close $f
- encoding convertto splat \u4e4e
+ encoding convertto splat \u4E4E
} -returnCodes error -cleanup {
file delete [file join [temporaryDirectory] tmp encoding splat.enc]
removeDirectory [file join tmp encoding]
@@ -289,45 +289,45 @@ test encoding-12.1 {LoadTableEncoding: normal encoding} {
set x [encoding convertto iso8859-3 \u0120]
append x [encoding convertto iso8859-3 \xD5]
append x [encoding convertfrom iso8859-3 \xD5]
-} "\xd5?\u120"
+} \xD5?\u0120
test encoding-12.2 {LoadTableEncoding: single-byte encoding} {
set x [encoding convertto iso8859-3 ab\u0120g]
append x [encoding convertfrom iso8859-3 ab\xD5g]
-} "ab\xd5gab\u120g"
+} ab\xD5gab\u0120g
test encoding-12.3 {LoadTableEncoding: multi-byte encoding} {
set x [encoding convertto shiftjis ab\u4E4Eg]
- append x [encoding convertfrom shiftjis ab\x8c\xc1g]
-} "ab\x8c\xc1gab\u4e4eg"
+ append x [encoding convertfrom shiftjis ab\x8C\xC1g]
+} ab\x8C\xC1gab\u4E4Eg
test encoding-12.4 {LoadTableEncoding: double-byte encoding} {
- set x [encoding convertto jis0208 \u4e4e\u3b1]
+ set x [encoding convertto jis0208 \u4E4E\u03B1]
append x [encoding convertfrom jis0208 8C&A]
-} "8C&A\u4e4e\u3b1"
+} 8C&A\u4E4E\u03B1
test encoding-12.5 {LoadTableEncoding: symbol encoding} {
- set x [encoding convertto symbol \u3b3]
- append x [encoding convertto symbol \u67]
- append x [encoding convertfrom symbol \x67]
-} "\x67\x67\u3b3"
+ set x [encoding convertto symbol \u03B3]
+ append x [encoding convertto symbol g]
+ append x [encoding convertfrom symbol g]
+} gg\u03B3
test encoding-12.6 {LoadTableEncoding: overflow in char value} ucs2 {
encoding convertto iso8859-3 \U010000
-} "?"
+} ?
test encoding-13.1 {LoadEscapeTable} {
- viewable [set x [encoding convertto iso2022 ab\u4e4e\u68d9g]]
-} [viewable "ab\x1b\$B8C\x1b\$\(DD%\x1b(Bg"]
+ viewable [set x [encoding convertto iso2022 ab\u4E4E\u68D9g]]
+} [viewable "ab\x1B\$B8C\x1B\$\(DD%\x1B(Bg"]
test encoding-14.1 {BinaryProc} {
encoding convertto identity \x12\x34\x56\xff\x69
} "\x12\x34\x56\xc3\xbf\x69"
test encoding-15.1 {UtfToUtfProc} {
- encoding convertto utf-8 \xa3
-} "\xc2\xa3"
+ encoding convertto utf-8 \xA3
+} "\xC2\xA3"
test encoding-15.2 {UtfToUtfProc null character output} testbytestring {
- binary scan [testbytestring [encoding convertto utf-8 \u0000]] H* z
+ binary scan [testbytestring [encoding convertto utf-8 \x00]] H* z
set z
} 00
test encoding-15.3 {UtfToUtfProc null character input} teststringbytes {
- set y [encoding convertfrom utf-8 [encoding convertto utf-8 \u0000]]
+ set y [encoding convertfrom utf-8 [encoding convertto utf-8 \x00]]
binary scan [teststringbytes $y] H* z
set z
} c080
@@ -407,18 +407,18 @@ test encoding-15.16 {UtfToUtfProc: Invalid 4-byte UTF-8, see [ed29806ba]} {
list [string length $x] $y
} "4 \xF0\xA0\xA1\xC2"
-test encoding-16.1 {UnicodeToUtfProc} {
+test encoding-16.1 {UnicodeToUtfProc} -body {
set val [encoding convertfrom unicode NN]
- list $val [format %x [scan $val %c]]
-} "\u4e4e 4e4e"
+ list $val [format %X [scan $val %c]]
+} -result "\u4E4E 4E4E"
test encoding-16.2 {UnicodeToUtfProc} -constraints fullutf -body {
set val [encoding convertfrom unicode "\xD8\xD8\xDC\xDC"]
list $val [format %x [scan $val %c]]
} -result "\U460DC 460dc"
test encoding-16.3 {UnicodeToUtfProc} -body {
set val [encoding convertfrom unicode "\xDC\xDC"]
- list $val [format %x [scan $val %c]]
-} -result "\uDCDC dcdc"
+ list $val [format %X [scan $val %c]]
+} -result "\uDCDC DCDC"
test encoding-17.1 {UtfToUnicodeProc} -constraints fullutf -body {
encoding convertto unicode "\U460DC"
@@ -430,8 +430,9 @@ test encoding-17.3 {UtfToUnicodeProc} -body {
encoding convertto unicode "\uD8D8"
} -result "\xD8\xD8"
-test encoding-18.1 {TableToUtfProc} {
-} {}
+test encoding-18.1 {TableToUtfProc on invalid input} -body {
+ list [catch {encoding convertto jis0208 \\} res] $res
+} -result {0 !)}
test encoding-19.1 {TableFromUtfProc} {
} {}
@@ -445,11 +446,11 @@ test encoding-21.1 {EscapeToUtfProc} {
test encoding-22.1 {EscapeFromUtfProc} {
} {}
-set iso2022encData "\u001b\$B;d\$I\$b\$G\$O!\"%A%C%W\$49XF~;~\$K\$4EPO?\$\$\$?\$@\$\$\$?\$4=;=j\$r%-%c%C%7%e%\"%&%H\$N:]\$N\u001b(B
-\u001b\$B>.@Z<jAwIU@h\$H\$7\$F;HMQ\$7\$F\$*\$j\$^\$9!#62\$lF~\$j\$^\$9\$,!\"@5\$7\$\$=;=j\$r\$4EPO?\$7\$J\$*\u001b(B
-\u001b\$B\$*4j\$\$\$\$\$?\$7\$^\$9!#\$^\$?!\"BgJQ62=L\$G\$9\$,!\"=;=jJQ99\$N\$\"\$H!\"F|K\\8l%5!<%S%9It!J\u001b(B
-casino_japanese@___.com \u001b\$B!K\$^\$G\$4=;=jJQ99:Q\$NO\"Mm\$r\$\$\$?\$@\$1\$J\$\$\$G\u001b(B
-\u001b\$B\$7\$g\$&\$+!)\u001b(B"
+set iso2022encData "\x1B\$B;d\$I\$b\$G\$O!\"%A%C%W\$49XF~;~\$K\$4EPO?\$\$\$?\$@\$\$\$?\$4=;=j\$r%-%c%C%7%e%\"%&%H\$N:]\$N\x1B(B
+\x1B\$B>.@Z<jAwIU@h\$H\$7\$F;HMQ\$7\$F\$*\$j\$^\$9!#62\$lF~\$j\$^\$9\$,!\"@5\$7\$\$=;=j\$r\$4EPO?\$7\$J\$*\x1B(B
+\x1B\$B\$*4j\$\$\$\$\$?\$7\$^\$9!#\$^\$?!\"BgJQ62=L\$G\$9\$,!\"=;=jJQ99\$N\$\"\$H!\"F|K\\8l%5!<%S%9It!J\x1B(B
+casino_japanese@___.com \x1B\$B!K\$^\$G\$4=;=jJQ99:Q\$NO\"Mm\$r\$\$\$?\$@\$1\$J\$\$\$G\x1B(B
+\x1B\$B\$7\$g\$&\$+!)\x1B(B"
set iso2022uniData [encoding convertfrom iso2022-jp $iso2022encData]
set iso2022uniData2 "\u79c1\u3069\u3082\u3067\u306f\u3001\u30c1\u30c3\u30d7\u3054\u8cfc\u5165\u6642\u306b\u3054\u767b\u9332\u3044\u305f\u3060\u3044\u305f\u3054\u4f4f\u6240\u3092\u30ad\u30e3\u30c3\u30b7\u30e5\u30a2\u30a6\u30c8\u306e\u969b\u306e
@@ -521,17 +522,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\u4e4e\u68d9g
+ puts ab\u4E4E\u68D9g
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 "\u4e4e\u4e5e\u4e5f"; # 3 Japanese Kanji letters
+ set a \u4E4E\u4E5E\u4E5F; # 3 Japanese Kanji letters
puts $a
} iso2022.tcl]
set f [open "|[list [interpreter] $file]"]
@@ -540,31 +541,31 @@ test encoding-24.3 {EscapeFreeProc on open channels} {stdio} {
close $f
removeFile iso2022.tcl
list $count [viewable $line]
-} [list 3 "\u4e4e\u4e5e\u4e5f (\\u4e4e\\u4e5e\\u4e5f)"]
+} [list 3 "\u4E4E\u4E5E\u4E5F (\\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]
@@ -618,20 +619,20 @@ proc foreach-jisx0208 {varName command} {
}
proc gen-jisx0208-euc-jp {code} {
binary format cc \
- [expr {($code >> 8) | 0x80}] [expr {($code & 0xff) | 0x80}]
+ [expr {($code >> 8) | 0x80}] [expr {($code & 0xFF) | 0x80}]
}
proc gen-jisx0208-iso2022-jp {code} {
binary format a3cca3 \
- "\x1b\$B" [expr {$code >> 8}] [expr {$code & 0xff}] "\x1b(B"
+ "\x1B\$B" [expr {$code >> 8}] [expr {$code & 0xFF}] "\x1B(B"
}
proc gen-jisx0208-cp932 {code} {
set c1 [expr {($code >> 8) | 0x80}]
set c2 [expr {($code & 0xff)| 0x80}]
if {$c1 % 2} {
- set c1 [expr {($c1 >> 1) + ($c1 < 0xdf ? 0x31 : 0x71)}]
- incr c2 [expr {- (0x60 + ($c2 < 0xe0))}]
+ set c1 [expr {($c1 >> 1) + ($c1 < 0xDF ? 0x31 : 0x71)}]
+ incr c2 [expr {- (0x60 + ($c2 < 0xE0))}]
} else {
- set c1 [expr {($c1 >> 1) + ($c1 < 0xdf ? 0x30 : 0x70)}]
+ set c1 [expr {($c1 >> 1) + ($c1 < 0xDF ? 0x30 : 0x70)}]
incr c2 -2
}
binary format cc $c1 $c2