zlib: Don't use PASTE for INTMAX error messages
[jimtcl.git] / tests / utf8.test
blob74a5aa8de4e92feb838873f37fff3222c8c65d9a
1 source [file dirname [info script]]/testing.tcl
3 needs constraint utf8
5 test utf8-1.1 "Pattern matching - ?" {
6         string match "abc?def" "abc\u00b5def"
7 } 1
9 test utf8-1.2 "Pattern matching - ?" {
10         string match "abc?def" "abc\u2704def"
11 } 1
13 test utf8-1.3 "Pattern utf-8 literal" {
14         string match "ab\u00b5\u2704?" "ab\u00b5\u2704x" 
15 } 1
17 test utf8-1.4 "Pattern utf-8 char sets" {
18         string match "a\[b\u00b5\]\u2704?" "a\u00b5\u2704x" 
19 } 1
21 test utf8-1.5 "Pattern utf-8 char sets" {
22         string match "a\[b\u00b5\]\u2704?" "a\u00b6\u2704x" 
23 } 0
24 test utf8-1.6 "Pattern utf-8 char sets" {
25         string match "a\[b\u00b5\]\u2704?" "ab\u2704x" 
26 } 1
27 test utf8-1.7 "Pattern utf-8 char sets" {
28         string match "a\[b\u00b5\]?" "a\u2704x"
29 } 0
30 test utf8-1.8 "Pattern utf-8 char sets" {
31         string match "a\[\u00b5-\u00c3\]" "a\ubd"
32 } 1
33 test utf8-1.9 "Pattern utf-8 char sets" {
34         string match "a\[\u00b5-\u00c3\]" "a\uc4"
35 } 0
37 test utf8-2.1 "Pattern utf-8 nocase" {
38         string match -nocase "a\u1edc\u1ef4*" "A\u1edd\u1ef5XX"
39 } 1
41 test utf8-2.2 "Pattern utf-8 case difference" {
42         string match "a\u1edc\u1ef4*" "A\u1edd\u1ef5XX"
43 } 0
45 test utf8-3.1 "lsearch -glob" {
46         lsearch -glob {1 d a\u00b5xyb c} a\ub5*b
47 } 2
49 test utf8-3.2 "switch -glob" {
50         switch -glob -- a\ub5xyb a\ub5*b { set x 1 } default { set x 0 }
51         set x
52 } 1
54 set x "\ub5test"
55 test utf8-3.3 "info procs" {
56         proc $x {} { info procs \[\ub5X]???? }
57         $x
58 } $x
60 test utf8-3.3 "info commands" {
61         info commands \[\ub5X]????
62 } $x
64 test utf8-3.4 "proc name with invalid utf-8" {
65         catch { proc ab\xc2 {} {} } msg
66 } 0
68 test utf8-3.5 "rename to invalid name" {
69         catch { rename ab\xc2 ab\xc3 } msg
70 } 0
72 catch {rename ab\xc3 ""}
74 test utf8-4.1 "split with utf-8" {
75         split "zy\u2702xw" x
76 } "zy\u2702 w"
78 test utf8-4.2 "split with utf-8" {
79         split "zy\u2702xw" \u2702
80 } "zy xw"
82 test utf8-4.2 "split with utf-8" {
83         split "zy\u2702xw" {}
84 } "z y \u2702 x w"
86 test utf8-5.1 "string first with utf-8" {
87         string first w "zy\u2702xw"
88 } 4
90 test utf8-5.2 "string first with utf-8" {
91         string first \u2702 "\ub5zy\u2702xw"
92 } 3
94 test utf8-5.3 "string first with utf-8" {
95         string first \u2704 "\ub5zy\u2702xw"
96 } -1
98 test utf8-5.4 "string first with utf-8" {
99         string first \u2702 "\ub5zy\u2702xw\u2702BB"
100 } 3
102 test utf8-6.1 "string last with utf-8" {
103         string last w "zy\u2702xw"
104 } 4
106 test utf8-6.2 "string last with utf-8" {
107         string last \u2702 "\ub5zy\u2702xw"
108 } 3
110 test utf8-6.3 "string last with utf-8" {
111         string last \u2704 "\ub5zy\u2702xw"
112 } -1
114 test utf8-6.4 "string last with utf-8" {
115         string last \u2702 "\ub5zy\u2702xw\u2702BB"
116 } 6
118 test utf8-7.1 "string reverse" {
119         string reverse \ub5Test\u2702
120 } \u2702tseT\ub5
122 test utf8-7.2 {append counts correctly} {
123         set x \u2702XYZ
124         append x \u2702XYZ
125         list [string length $x] [string bytelength $x]
126 } {8 12}
128 test utf8-7.3 {Upper, lower for titlecase utf-8} {
129         list [string toupper \u01c5] [string tolower \u01c5]
130 } "\u01c4 \u01c6"
132 test utf8-7.4 {Case folding may change encoded length} {
133         list [string bytelength \u0131] [string bytelength [string toupper \u0131]]
134 } {2 1}
136 test utf8-8.1 {Chars outside the BMP} jim {
137         string length \u{12000}\u{13000}
138 } 2
140 test utf8-8.2 {Chars outside the BMP} jim {
141         string match "ab\[\u{12000}c\]d" ab\u{12000}d
142 } 1
144 test utf8-8.3 {Chars outside the BMP} jim {
145         string last d "ab\u{101fff}cd"
146 } 4
148 test utf8-8.4 {Longer sequences} {
149         string length \u12000
150 } 2
152 testreport