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