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