author | Jan Vrany <jan.vrany@fit.cvut.cz> |
Fri, 04 Aug 2017 12:09:09 +0100 | |
branch | jv |
changeset 1952 | 2a5f8c52b7a1 |
parent 1546 | 662fa681379c |
child 1974 | f2eaf05205d6 |
permissions | -rw-r--r-- |
1447 | 1 |
"{ Package: 'stx:goodies/regression' }" |
283 | 2 |
|
3 |
"{ NameSpace: RegressionTests }" |
|
4 |
||
5 |
TestCase subclass:#StringTests |
|
1421 | 6 |
instanceVariableNames:'' |
7 |
classVariableNames:'' |
|
8 |
poolDictionaries:'' |
|
9 |
category:'tests-Regression-Collections' |
|
283 | 10 |
! |
11 |
||
12 |
||
1425 | 13 |
!StringTests class methodsFor:'queries'! |
14 |
||
15 |
coveredClassNames |
|
16 |
"should be redefined to return a collection of classes which are tested by |
|
1496 | 17 |
this suite/case. |
1425 | 18 |
If not redefined, coveredPackageNames should be. |
19 |
||
20 |
These classes can be instrumented for coverage analysis, |
|
21 |
before running the suite to provide coverage analysis/report" |
|
22 |
||
23 |
^ #( String CharacterArray ) |
|
24 |
||
25 |
"Created: / 06-07-2011 / 21:27:03 / cg" |
|
26 |
! ! |
|
27 |
||
288 | 28 |
!StringTests methodsFor:'helpers'! |
284 | 29 |
|
288 | 30 |
runAccessTestsOnInstancesOf:aStringClass |
874
7936c9ee23d5
class: RegressionTests::StringTests
Claus Gittinger <cg@exept.de>
parents:
873
diff
changeset
|
31 |
|str s0 s1 s2 s3 s4 t| |
284 | 32 |
|
33 |
0 to:33 do:[:l | |
|
702
4c5fb5598e9e
changed: #runAccessTestsOnInstancesOf:
Claus Gittinger <cg@exept.de>
parents:
635
diff
changeset
|
34 |
str := aStringClass new:l. |
4c5fb5598e9e
changed: #runAccessTestsOnInstancesOf:
Claus Gittinger <cg@exept.de>
parents:
635
diff
changeset
|
35 |
str atAllPut:(Character space). |
4c5fb5598e9e
changed: #runAccessTestsOnInstancesOf:
Claus Gittinger <cg@exept.de>
parents:
635
diff
changeset
|
36 |
self assert:( str isBlank ). |
284 | 37 |
|
702
4c5fb5598e9e
changed: #runAccessTestsOnInstancesOf:
Claus Gittinger <cg@exept.de>
parents:
635
diff
changeset
|
38 |
1 to:l do:[:pos | |
4c5fb5598e9e
changed: #runAccessTestsOnInstancesOf:
Claus Gittinger <cg@exept.de>
parents:
635
diff
changeset
|
39 |
str at:pos put:$a. |
4c5fb5598e9e
changed: #runAccessTestsOnInstancesOf:
Claus Gittinger <cg@exept.de>
parents:
635
diff
changeset
|
40 |
self assert:( str isBlank not ). |
4c5fb5598e9e
changed: #runAccessTestsOnInstancesOf:
Claus Gittinger <cg@exept.de>
parents:
635
diff
changeset
|
41 |
str at:pos put:(Character space). |
4c5fb5598e9e
changed: #runAccessTestsOnInstancesOf:
Claus Gittinger <cg@exept.de>
parents:
635
diff
changeset
|
42 |
]. |
284 | 43 |
]. |
44 |
||
288 | 45 |
s0 := aStringClass new:0. |
287 | 46 |
self assert:s0 isEmpty. |
47 |
self assert:s0 isEmptyOrNil. |
|
48 |
self assert:s0 size == 0. |
|
49 |
||
288 | 50 |
s1 := (aStringClass new:5) replaceFrom:1 with:'hello'. |
51 |
s2 := (aStringClass new:6) replaceFrom:1 with:' world'. |
|
285 | 52 |
self assert:(s1 , s2) size == 11. |
288 | 53 |
self assert:(s1 , s2) class == aStringClass. |
285 | 54 |
self assert:(s1 = 'hello'). |
55 |
self assert:(s2 = ' world'). |
|
56 |
self assert:(s1 size == 5). |
|
57 |
self assert:(s2 size == 6). |
|
288 | 58 |
|
285 | 59 |
self assert:(s1 = 'hello'). |
60 |
self assert:(s1 asSymbol == #'hello'). |
|
61 |
self assert:(s1 copyFrom:1) = 'hello'. |
|
288 | 62 |
self assert:(s1 copyFrom:1) class == aStringClass. |
285 | 63 |
self assert:(s1 copyFrom:1 to:3) = 'hel'. |
288 | 64 |
self assert:(s1 copyFrom:1 to:3) class == aStringClass. |
285 | 65 |
self assert:(s1 copyWith:$X) = 'helloX'. |
288 | 66 |
self assert:(s1 copyWith:$X) class == aStringClass. |
285 | 67 |
self assert:(s1 endsWith:'llo'). |
68 |
self assert:(s1 startsWith:'hel'). |
|
286 | 69 |
|
702
4c5fb5598e9e
changed: #runAccessTestsOnInstancesOf:
Claus Gittinger <cg@exept.de>
parents:
635
diff
changeset
|
70 |
self assert:(t := s1 identityIndexOf:$h) == 1 description:('identityIndex is %1 (should be 1)' bindWith:t). |
4c5fb5598e9e
changed: #runAccessTestsOnInstancesOf:
Claus Gittinger <cg@exept.de>
parents:
635
diff
changeset
|
71 |
self assert:(t := s1 identityIndexOf:$l) == 3 description:('identityIndex is %1 (should be 3)' bindWith:t). |
4c5fb5598e9e
changed: #runAccessTestsOnInstancesOf:
Claus Gittinger <cg@exept.de>
parents:
635
diff
changeset
|
72 |
self assert:(t := s1 identityIndexOf:$L) == 0 description:('identityIndex is %1 (should be 0)' bindWith:t). |
288 | 73 |
|
74 |
self assert:(s1 identityIndexOf:$h startingAt:1) == 1. |
|
75 |
self assert:(s1 identityIndexOf:$h startingAt:2) == 0. |
|
76 |
self assert:(s1 identityIndexOf:$e startingAt:1) == 2. |
|
77 |
self assert:(s1 identityIndexOf:$e startingAt:2) == 2. |
|
78 |
self assert:(s1 identityIndexOf:$l startingAt:1) == 3. |
|
79 |
self assert:(s1 identityIndexOf:$l startingAt:2) == 3. |
|
80 |
self assert:(s1 identityIndexOf:$l startingAt:3) == 3. |
|
81 |
self assert:(s1 identityIndexOf:$l startingAt:4) == 4. |
|
82 |
self assert:(s1 identityIndexOf:$l startingAt:5) == 0. |
|
83 |
self assert:(s1 identityIndexOf:$l startingAt:6) == 0. |
|
84 |
||
286 | 85 |
self assert:(s1 indexOf:$h) == 1. |
86 |
self assert:(s1 indexOf:$l) == 3. |
|
287 | 87 |
self assert:(s1 indexOf:$L) == 0. |
874
7936c9ee23d5
class: RegressionTests::StringTests
Claus Gittinger <cg@exept.de>
parents:
873
diff
changeset
|
88 |
self assert:(s1 indexOf:$A) == 0. |
288 | 89 |
|
286 | 90 |
self assert:(s1 indexOf:$h startingAt:1) == 1. |
91 |
self assert:(s1 indexOf:$h startingAt:2) == 0. |
|
92 |
self assert:(s1 indexOf:$e startingAt:1) == 2. |
|
93 |
self assert:(s1 indexOf:$e startingAt:2) == 2. |
|
94 |
self assert:(s1 indexOf:$l startingAt:1) == 3. |
|
95 |
self assert:(s1 indexOf:$l startingAt:2) == 3. |
|
96 |
self assert:(s1 indexOf:$l startingAt:3) == 3. |
|
97 |
self assert:(s1 indexOf:$l startingAt:4) == 4. |
|
98 |
self assert:(s1 indexOf:$l startingAt:5) == 0. |
|
99 |
self assert:(s1 indexOf:$l startingAt:6) == 0. |
|
288 | 100 |
|
286 | 101 |
self assert:(s1 includes:$l). |
102 |
self assert:(s1 includes:$L) not. |
|
288 | 103 |
|
287 | 104 |
self assert:(s1 includesAny:'a') not. |
105 |
self assert:(s1 includesAny:'ab') not. |
|
106 |
self assert:(s1 includesAny:'abc') not. |
|
107 |
self assert:(s1 includesAny:'abcd') not. |
|
108 |
self assert:(s1 includesAny:'abcde'). |
|
109 |
self assert:(s1 includesAny:'e'). |
|
110 |
self assert:(s1 includesAny:'ae'). |
|
111 |
self assert:(s1 includesAny:'ea'). |
|
112 |
self assert:(s1 includesAny:'abe'). |
|
113 |
self assert:(s1 includesAny:'eab'). |
|
114 |
self assert:(s1 includesAny:'aeb'). |
|
115 |
self assert:(s1 includesAny:'abce'). |
|
116 |
self assert:(s1 includesAny:'eabc'). |
|
117 |
self assert:(s1 includesAny:'aebc'). |
|
118 |
self assert:(s1 includesAny:'abec'). |
|
119 |
self assert:(s1 includesAny:'abcde'). |
|
702
4c5fb5598e9e
changed: #runAccessTestsOnInstancesOf:
Claus Gittinger <cg@exept.de>
parents:
635
diff
changeset
|
120 |
" 12345678901234567890 " |
288 | 121 |
s3 := (aStringClass new:20) replaceFrom:1 with:'12 45,78;01.34-67+90'. |
122 |
t := s3 asCollectionOfSubstringsSeparatedBy:$,. |
|
123 |
self assert:(t size = 2). |
|
124 |
self assert:(t first = '12 45'). |
|
125 |
self assert:(t second = '78;01.34-67+90'). |
|
126 |
||
127 |
t := s3 asCollectionOfSubstringsSeparatedByAny:',;. '. |
|
128 |
self assert:(t size = 5). |
|
129 |
self assert:(t first = '12'). |
|
130 |
self assert:(t second = '45'). |
|
131 |
self assert:(t third = '78'). |
|
132 |
self assert:(t fourth = '01'). |
|
133 |
self assert:(t fifth = '34-67+90'). |
|
874
7936c9ee23d5
class: RegressionTests::StringTests
Claus Gittinger <cg@exept.de>
parents:
873
diff
changeset
|
134 |
|
7936c9ee23d5
class: RegressionTests::StringTests
Claus Gittinger <cg@exept.de>
parents:
873
diff
changeset
|
135 |
s4 := (aStringClass new:10) replaceFrom:1 with:'123',Character tab,'567',Character cr,'90'. |
7936c9ee23d5
class: RegressionTests::StringTests
Claus Gittinger <cg@exept.de>
parents:
873
diff
changeset
|
136 |
self assert:(s4 size = 10). |
7936c9ee23d5
class: RegressionTests::StringTests
Claus Gittinger <cg@exept.de>
parents:
873
diff
changeset
|
137 |
self assert:(s4 indexOfSeparatorStartingAt:1) = 4. |
7936c9ee23d5
class: RegressionTests::StringTests
Claus Gittinger <cg@exept.de>
parents:
873
diff
changeset
|
138 |
self assert:(s4 indexOfSeparatorStartingAt:3) = 4. |
7936c9ee23d5
class: RegressionTests::StringTests
Claus Gittinger <cg@exept.de>
parents:
873
diff
changeset
|
139 |
self assert:(s4 indexOfSeparatorStartingAt:4) = 4. |
7936c9ee23d5
class: RegressionTests::StringTests
Claus Gittinger <cg@exept.de>
parents:
873
diff
changeset
|
140 |
self assert:(s4 indexOfSeparatorStartingAt:5) = 8. |
7936c9ee23d5
class: RegressionTests::StringTests
Claus Gittinger <cg@exept.de>
parents:
873
diff
changeset
|
141 |
self assert:(s4 indexOfControlCharacterStartingAt:1) = 4. |
7936c9ee23d5
class: RegressionTests::StringTests
Claus Gittinger <cg@exept.de>
parents:
873
diff
changeset
|
142 |
self assert:(s4 indexOfNonSeparatorStartingAt:1) = 1. |
7936c9ee23d5
class: RegressionTests::StringTests
Claus Gittinger <cg@exept.de>
parents:
873
diff
changeset
|
143 |
self assert:(s4 indexOfNonSeparatorStartingAt:3) = 3. |
7936c9ee23d5
class: RegressionTests::StringTests
Claus Gittinger <cg@exept.de>
parents:
873
diff
changeset
|
144 |
self assert:(s4 indexOfNonSeparatorStartingAt:4) = 5. |
7936c9ee23d5
class: RegressionTests::StringTests
Claus Gittinger <cg@exept.de>
parents:
873
diff
changeset
|
145 |
self assert:(s4 indexOfNonSeparatorStartingAt:5) = 5. |
352 | 146 |
! ! |
147 |
||
148 |
!StringTests methodsFor:'tests'! |
|
288 | 149 |
|
150 |
test01_access |
|
151 |
0 to:33 do:[:l | |
|
1496 | 152 |
|str| |
288 | 153 |
|
1496 | 154 |
str := String new:l. |
155 |
str atAllPut:(Character space). |
|
156 |
self assert:( str isBlank ). |
|
157 |
self assert:((str size == 0) or: [(str first) == Character space.]). |
|
288 | 158 |
|
1496 | 159 |
1 to:l do:[:pos | |
160 |
str at:pos put:$a. |
|
161 |
self assert:( str isBlank not ). |
|
162 |
self assert:((str at:pos) == $a). |
|
163 |
str at:pos put:(Character space). |
|
164 |
]. |
|
288 | 165 |
]. |
166 |
self runAccessTestsOnInstancesOf:String |
|
167 |
||
168 |
" |
|
169 |
self new test01_access |
|
170 |
" |
|
171 |
! |
|
172 |
||
173 |
test02_subclassAccess |
|
174 |
|myStringClass s1| |
|
175 |
||
176 |
Class withoutUpdatingChangesDo:[ |
|
1421 | 177 |
myStringClass := String |
178 |
subclass:#'MyString' |
|
179 |
instanceVariableNames:'foo' |
|
180 |
classVariableNames:'' |
|
181 |
poolDictionaries:nil. |
|
182 |
myStringClass compile:'foo ^foo'. |
|
183 |
myStringClass compile:'foo:arg foo := arg'. |
|
288 | 184 |
]. |
185 |
||
186 |
s1 := (myStringClass new:5) replaceFrom:1 with:'hello'. |
|
187 |
self assert:(s1 foo isNil). |
|
188 |
self assert:(s1 size == 5). |
|
874
7936c9ee23d5
class: RegressionTests::StringTests
Claus Gittinger <cg@exept.de>
parents:
873
diff
changeset
|
189 |
s1 foo:16r11413344. "/ ensure there is a $A inside (hex 41) |
7936c9ee23d5
class: RegressionTests::StringTests
Claus Gittinger <cg@exept.de>
parents:
873
diff
changeset
|
190 |
self assert:(s1 foo == 16r11413344). |
288 | 191 |
self assert:(s1 = 'hello'). |
874
7936c9ee23d5
class: RegressionTests::StringTests
Claus Gittinger <cg@exept.de>
parents:
873
diff
changeset
|
192 |
self assert:(s1 deepCopy foo == 16r11413344). |
7936c9ee23d5
class: RegressionTests::StringTests
Claus Gittinger <cg@exept.de>
parents:
873
diff
changeset
|
193 |
|
7936c9ee23d5
class: RegressionTests::StringTests
Claus Gittinger <cg@exept.de>
parents:
873
diff
changeset
|
194 |
self assert:((s1 indexOf:$A) == 0). "/ should not find the A |
7936c9ee23d5
class: RegressionTests::StringTests
Claus Gittinger <cg@exept.de>
parents:
873
diff
changeset
|
195 |
self assert:((s1 identityIndexOf:$A) == 0). "/ should not find the A |
7936c9ee23d5
class: RegressionTests::StringTests
Claus Gittinger <cg@exept.de>
parents:
873
diff
changeset
|
196 |
self assert:((s1 findFirst:[:ch | ch == $A]) == 0). "/ should not find the A |
288 | 197 |
|
198 |
self runAccessTestsOnInstancesOf:myStringClass. |
|
285 | 199 |
|
284 | 200 |
" |
201 |
self new test02_subclassAccess |
|
202 |
" |
|
203 |
! |
|
204 |
||
205 |
test10_Contains8BitCharacters |
|
288 | 206 |
0 to:65 do:[:l | |
1421 | 207 |
|str| |
283 | 208 |
|
1421 | 209 |
str := String new:l. |
210 |
str atAllPut:(Character value:16r7F). |
|
211 |
self assert:( str contains8BitCharacters not ). |
|
283 | 212 |
|
1421 | 213 |
1 to:l do:[:pos | |
214 |
str at:pos put:(Character value:16r80). |
|
215 |
self assert:( str contains8BitCharacters ). |
|
216 |
str at:pos put:(Character value:16r7F). |
|
217 |
]. |
|
283 | 218 |
]. |
219 |
||
220 |
" |
|
284 | 221 |
self new test10_Contains8BitCharacters |
283 | 222 |
" |
288 | 223 |
! |
224 |
||
1426 | 225 |
test11_IsEmpty |
226 |
|nul n| |
|
227 |
nul := 0 asCharacter. |
|
228 |
n := 1. |
|
229 |
self assert:('' isEmpty). |
|
230 |
self assert:(' ' isEmpty not). |
|
231 |
self assert:(nul asCharacter asString isEmpty not). |
|
232 |
self assert:(('' , nul) isEmpty not). |
|
233 |
self assert:((String new:0) isEmpty). |
|
234 |
self assert:((String new:17 withAll:nul) isEmpty not). |
|
235 |
||
1546
662fa681379c
Fixes StringTests>>test11_IsEmpty to handle allocation failures
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1500
diff
changeset
|
236 |
[ |
662fa681379c
Fixes StringTests>>test11_IsEmpty to handle allocation failures
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1500
diff
changeset
|
237 |
29 timesRepeat:[ |
662fa681379c
Fixes StringTests>>test11_IsEmpty to handle allocation failures
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1500
diff
changeset
|
238 |
|s| |
1426 | 239 |
|
1546
662fa681379c
Fixes StringTests>>test11_IsEmpty to handle allocation failures
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1500
diff
changeset
|
240 |
s := String new:(n + 17). |
662fa681379c
Fixes StringTests>>test11_IsEmpty to handle allocation failures
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1500
diff
changeset
|
241 |
self assert:(s isEmpty not). |
662fa681379c
Fixes StringTests>>test11_IsEmpty to handle allocation failures
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1500
diff
changeset
|
242 |
n := n * 2. |
662fa681379c
Fixes StringTests>>test11_IsEmpty to handle allocation failures
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1500
diff
changeset
|
243 |
]. |
662fa681379c
Fixes StringTests>>test11_IsEmpty to handle allocation failures
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1500
diff
changeset
|
244 |
] on: AllocationFailure do:[:ex | |
662fa681379c
Fixes StringTests>>test11_IsEmpty to handle allocation failures
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1500
diff
changeset
|
245 |
"/ This is to be expected, we're trying to allocate up to 512MB |
662fa681379c
Fixes StringTests>>test11_IsEmpty to handle allocation failures
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1500
diff
changeset
|
246 |
"/ which migh not be possible on 32bit system... |
1426 | 247 |
]. |
248 |
self assert:((String new:17 withAll:nul) isEmpty not). |
|
249 |
self assert:((String new:0 withAll:nul) isEmpty). |
|
250 |
" |
|
1429 | 251 |
self new test11_IsEmpty |
252 |
" |
|
1546
662fa681379c
Fixes StringTests>>test11_IsEmpty to handle allocation failures
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1500
diff
changeset
|
253 |
|
662fa681379c
Fixes StringTests>>test11_IsEmpty to handle allocation failures
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1500
diff
changeset
|
254 |
"Modified (format): / 30-11-2016 / 13:49:26 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
1426 | 255 |
! |
256 |
||
257 |
test12_Comparison |
|
258 |
0 to: 255 do: [ :i | |
|
1496 | 259 |
|s t| |
1426 | 260 |
|
1496 | 261 |
1 to: 9 do: [ :j | |
262 |
s := String new:j withAll:(i asCharacter). |
|
263 |
t := s copy. |
|
1426 | 264 |
|
1496 | 265 |
self assert:(s notNil). |
266 |
self assert:(s = s). |
|
267 |
self assert:(s ~= s) not. |
|
268 |
self assert:(s < s) not. |
|
269 |
self assert:(s > s) not. |
|
270 |
self assert:(s = (s,s)) not. |
|
1426 | 271 |
|
1496 | 272 |
self assert:(t notNil). |
273 |
self assert:(s = t). |
|
274 |
self assert:(s ~= t) not. |
|
275 |
self assert:(s < t) not. |
|
276 |
self assert:(s > t) not. |
|
1426 | 277 |
|
1496 | 278 |
self assert:((s = nil) == ((s ~= nil) not)). |
279 |
self assert:((s = '') == ((s ~= '') not)). |
|
280 |
]. |
|
1426 | 281 |
|
1496 | 282 |
s := i asCharacter asString. |
283 |
0 to: 255 do: [ :j | |
|
284 |
t := j asCharacter asString. |
|
285 |
self assert:(t notNil). |
|
1426 | 286 |
|
1496 | 287 |
self assert:((s = t) == ((s ~= t) not)). |
288 |
] |
|
1426 | 289 |
]. |
290 |
||
291 |
" |
|
292 |
self new test12_Comparison |
|
293 |
" |
|
294 |
! |
|
295 |
||
296 |
test15_CompareWithCollating |
|
297 |
| nul | |
|
298 |
||
299 |
nul := 0 asCharacter asString. |
|
300 |
self assert:('' compareWith:'' collating:true) == 0. |
|
301 |
self assert:('' compareWith:'' collating:false) == 0. |
|
1496 | 302 |
self assert:(nul compareWith:(255 asCharacter asString) collating:false) == -1. |
1426 | 303 |
self assert:((255 asCharacter asString) compareWith:nul collating:false) == 1. |
1433 | 304 |
"/ This will fail and is a WONTFIX |
305 |
"/ self assert:((('' compareWith:nul collating:false) == 0) == ('' = nul)). |
|
1426 | 306 |
|
307 |
0 to: 255 do: [ :i | |
|
1496 | 308 |
|s| |
1426 | 309 |
|
1496 | 310 |
s := i asCharacter asString. |
311 |
self assert:(s notNil). |
|
1426 | 312 |
|
1497 | 313 |
"/ This will fail and is a WONTFIX |
314 |
"/ self assert:('' compareWith:s collating:false) ~= 0. |
|
1496 | 315 |
self assert:('' compareWith:s collating:false) == ((s compareWith:'' collating:false) negated). |
1426 | 316 |
|
1496 | 317 |
0 to: 255 do: [ :j | |
318 |
| t | |
|
319 |
t := j asCharacter asString. |
|
320 |
self assert:(t notNil). |
|
1426 | 321 |
|
1496 | 322 |
self assert:(((s compareWith:t collating:false) == -1) == (s < t)). |
323 |
self assert:(((s compareWith:t collating:false) == 0) == (s = t)). |
|
324 |
self assert:(((s compareWith:t collating:false) == 1) == (s > t)). |
|
325 |
self assert:(((s compareWith:t collating:true) == -1) == (s < t)). |
|
326 |
self assert:(((s compareWith:t collating:true) == 0) == (s = t)). |
|
327 |
self assert:(((s compareWith:t collating:true) == 1) == (s > t)). |
|
328 |
] |
|
1426 | 329 |
]. |
330 |
||
331 |
0 to: 9 do: [ :i | |
|
1496 | 332 |
0 to: 255 do: [ :j | |
333 |
|s t| |
|
334 |
s := String new:i withAll:(j asCharacter). |
|
335 |
t := s copy. |
|
1426 | 336 |
|
1496 | 337 |
self assert: (s compareWith:s collating:false) == 0. |
338 |
self assert: (s compareWith:s collating:true) == 0. |
|
339 |
self assert: (s compareWith:t collating:false) == 0. |
|
340 |
self assert: (s compareWith:t collating:true) == 0 |
|
341 |
] |
|
1426 | 342 |
]. |
343 |
||
344 |
" |
|
345 |
self new test15_CompareWithCollating |
|
346 |
" |
|
347 |
! |
|
348 |
||
288 | 349 |
test20_literalsAreReadonly |
605
6f0411c4d46f
changed: #test20_literalsAreReadonly
Claus Gittinger <cg@exept.de>
parents:
571
diff
changeset
|
350 |
|myClass s1 l2 s2 parserFlags compiler| |
6f0411c4d46f
changed: #test20_literalsAreReadonly
Claus Gittinger <cg@exept.de>
parents:
571
diff
changeset
|
351 |
|
6f0411c4d46f
changed: #test20_literalsAreReadonly
Claus Gittinger <cg@exept.de>
parents:
571
diff
changeset
|
352 |
parserFlags := Compiler new parserFlags copy. |
6f0411c4d46f
changed: #test20_literalsAreReadonly
Claus Gittinger <cg@exept.de>
parents:
571
diff
changeset
|
353 |
parserFlags stringsAreImmutable:true. |
6f0411c4d46f
changed: #test20_literalsAreReadonly
Claus Gittinger <cg@exept.de>
parents:
571
diff
changeset
|
354 |
parserFlags arraysAreImmutable:true. |
288 | 355 |
|
356 |
Class withoutUpdatingChangesDo:[ |
|
1421 | 357 |
myClass := Object |
358 |
subclass:#'MyClass' |
|
359 |
instanceVariableNames:'' |
|
360 |
classVariableNames:'' |
|
361 |
poolDictionaries:nil. |
|
605
6f0411c4d46f
changed: #test20_literalsAreReadonly
Claus Gittinger <cg@exept.de>
parents:
571
diff
changeset
|
362 |
|
1421 | 363 |
compiler := myClass compilerClass new. |
364 |
compiler parserFlags:parserFlags. |
|
365 |
compiler compile:'lit1 ^''hello''' forClass:myClass install:true. |
|
605
6f0411c4d46f
changed: #test20_literalsAreReadonly
Claus Gittinger <cg@exept.de>
parents:
571
diff
changeset
|
366 |
|
1421 | 367 |
compiler := myClass compilerClass new. |
368 |
compiler parserFlags:parserFlags. |
|
369 |
compiler compile:'lit2 ^#(''foo'' ''bar'' ''baz'')' forClass:myClass install:true. |
|
288 | 370 |
]. |
371 |
||
372 |
s1 := myClass new perform:#lit1. |
|
373 |
self assert:(s1 isString). |
|
374 |
self assert:(s1 class == ImmutableString). |
|
375 |
self should:[ s1 at:1 put:$H ] raise:Error. |
|
376 |
||
377 |
l2 := myClass new perform:#lit2. |
|
378 |
self assert:(l2 isArray). |
|
379 |
self assert:(l2 class == ImmutableArray). |
|
380 |
self should:[ l2 at:1 put:$H ] raise:Error. |
|
381 |
s2 := l2 at:1. |
|
382 |
self assert:(s2 isString). |
|
383 |
self assert:(s2 class == ImmutableString). |
|
384 |
self should:[ s2 at:1 put:$H ] raise:Error. |
|
385 |
||
386 |
" |
|
387 |
self new test20_literalsAreReadonly |
|
388 |
" |
|
605
6f0411c4d46f
changed: #test20_literalsAreReadonly
Claus Gittinger <cg@exept.de>
parents:
571
diff
changeset
|
389 |
|
6f0411c4d46f
changed: #test20_literalsAreReadonly
Claus Gittinger <cg@exept.de>
parents:
571
diff
changeset
|
390 |
"Modified: / 02-08-2011 / 19:30:53 / cg" |
352 | 391 |
! |
392 |
||
1418 | 393 |
test30_indexOfSubCollection |
352 | 394 |
|i| |
395 |
"/ 12345678901 |
|
396 |
i := 'hello world' indexOfSubCollection:'world' startingAt:1 ifAbsent:0 caseSensitive:true. |
|
397 |
self assert:(i == 7). |
|
398 |
i := 'hello wOrLd' indexOfSubCollection:'world' startingAt:1 ifAbsent:0 caseSensitive:true. |
|
399 |
self assert:(i == 0). |
|
400 |
i := 'hello wOrLd' indexOfSubCollection:'world' startingAt:1 ifAbsent:0 caseSensitive:false. |
|
401 |
self assert:(i == 7). |
|
402 |
i := 'hello wOrLd' indexOfSubCollection:'ll' startingAt:1 ifAbsent:0 caseSensitive:false. |
|
403 |
self assert:(i == 3). |
|
404 |
||
405 |
i := 'hello wOrLd yellow' indexOfSubCollection:'ll' startingAt:1 ifAbsent:0 caseSensitive:false. |
|
406 |
self assert:(i == 3). |
|
407 |
i := 'hello wOrLd yellow' indexOfSubCollection:'ll' startingAt:3 ifAbsent:0 caseSensitive:false. |
|
408 |
self assert:(i == 3). |
|
409 |
i := 'hello wOrLd yellow' indexOfSubCollection:'ll' startingAt:4 ifAbsent:0 caseSensitive:false. |
|
410 |
self assert:(i == 15). |
|
411 |
||
353 | 412 |
i := 'hello wOrLd yellow' indexOfSubCollection:'low' startingAt:1 ifAbsent:0 caseSensitive:false. |
413 |
self assert:(i == 16). |
|
414 |
i := 'hello wOrLd yellow' indexOfSubCollection:'low' startingAt:17 ifAbsent:0 caseSensitive:false. |
|
415 |
self assert:(i == 0). |
|
416 |
i := 'hello wOrLd yellow' indexOfSubCollection:'low' startingAt:18 ifAbsent:0 caseSensitive:false. |
|
417 |
self assert:(i == 0). |
|
418 |
||
352 | 419 |
" |
1418 | 420 |
self new test30_indexOfSubCollection |
352 | 421 |
" |
570 | 422 |
! |
423 |
||
424 |
test40_indexOfAny |
|
1426 | 425 |
|s i collection| |
570 | 426 |
|
427 |
s := 'Some Sample Generators (74035660-d1f6-11df-9ab3-00ff7b08316c)'. |
|
428 |
1 to:s size do:[:start | |
|
1480 | 429 |
i := s indexOfAny:'-' startingAt:start. |
430 |
self assert:(i == 0 or:[ i >= start]). |
|
431 |
(i ~~ 0) ifTrue:[ |
|
432 |
self assert:(s at:i) == $- |
|
433 |
]. |
|
1308 | 434 |
]. |
1480 | 435 |
"/ 123456789012 |
1308 | 436 |
s := 'bla bla 1234'. |
437 |
1 to:s size do:[:start | |
|
1480 | 438 |
i := s indexOfAny:'1234' startingAt:start. |
439 |
self assert:(i == 0 or:[ i >= start]). |
|
440 |
(i == 9) ifTrue:[ self assert:((s at:i) == $1) ]. |
|
441 |
(i == 10) ifTrue:[ self assert:((s at:i) == $2) ]. |
|
442 |
(i == 11) ifTrue:[ self assert:((s at:i) == $3) ]. |
|
443 |
(i == 12) ifTrue:[ self assert:((s at:i) == $4) ]. |
|
570 | 444 |
]. |
445 |
||
1426 | 446 |
collection := #($o, $l, $o). |
447 |
"/ 12345678901 |
|
448 |
i := 'hello world' indexOfAny:collection startingAt:1. |
|
449 |
self assert:(i == 3). |
|
450 |
i := 'hello world' indexOfAny:collection startingAt:2. |
|
451 |
self assert:(i == 3). |
|
452 |
i := 'hello world' indexOfAny:collection startingAt:3. |
|
1496 | 453 |
self assert:(i == 3). |
1426 | 454 |
i := 'hello world' indexOfAny:collection startingAt:4. |
1496 | 455 |
self assert:(i == 4). |
1426 | 456 |
i := 'hello world' indexOfAny:collection startingAt:5. |
1496 | 457 |
self assert:(i == 5). |
1426 | 458 |
i := 'hello world' indexOfAny:collection startingAt:6. |
1496 | 459 |
self assert:(i == 8). |
1426 | 460 |
i := 'hello world' indexOfAny:collection startingAt:7. |
461 |
self assert:(i == 8). |
|
462 |
i := 'hello world' indexOfAny:collection startingAt:8. |
|
1496 | 463 |
self assert:(i == 8). |
1426 | 464 |
i := 'hello world' indexOfAny:collection startingAt:9. |
1496 | 465 |
self assert:(i == 10). |
1426 | 466 |
i := 'hello world' indexOfAny:collection startingAt:10. |
1496 | 467 |
self assert:(i == 10). |
1426 | 468 |
i := 'hello world' indexOfAny:collection startingAt:11. |
469 |
self assert:(i == 0). |
|
470 |
i := 'hello world' indexOfAny:collection startingAt:12. |
|
471 |
self assert:(i == 0). |
|
472 |
i := 'hello world' indexOfAny:collection startingAt:10000. |
|
473 |
self assert:(i == 0). |
|
570 | 474 |
" |
475 |
self new test40_indexOfAny |
|
476 |
" |
|
477 |
||
478 |
"Created: / 29-10-2010 / 14:58:21 / cg" |
|
571 | 479 |
! |
480 |
||
1308 | 481 |
test41_contains |
482 |
|s| |
|
483 |
||
484 |
s := 'abcdefg'. |
|
485 |
self assert:(s contains:[:ch | ch == $a]). |
|
486 |
self assert:(s contains:[:ch | ch == $A]) not. |
|
487 |
self assert:(s contains:[:ch | ch == $1]) not. |
|
1426 | 488 |
self assert:(s contains:[:ch | ch == (0 asCharacter)]) not. |
1308 | 489 |
" |
490 |
self new test41_contains |
|
491 |
" |
|
492 |
! |
|
493 |
||
1420 | 494 |
test42_includesAny |
495 |
|s| |
|
496 |
||
497 |
1 to:20 do:[:na | |
|
1496 | 498 |
s := (String new:na withAll:$a),'bla bla 1234'. |
499 |
self assert:( s includesAny:'12'). |
|
500 |
self assert:( s includesAny:'21'). |
|
501 |
self assert:( s includesAny:'15'). |
|
502 |
self assert:( s includesAny:'51'). |
|
503 |
self assert:( s includesAny:'45'). |
|
504 |
self assert:( s includesAny:'54'). |
|
505 |
self assert:( s includesAny:'56') not. |
|
1420 | 506 |
]. |
1496 | 507 |
|
1420 | 508 |
" |
509 |
self new test42_includesAny |
|
510 |
" |
|
1421 | 511 |
! |
1420 | 512 |
|
1421 | 513 |
test43_occurrencesOf |
1418 | 514 |
|s| |
515 |
||
516 |
"/ 12345678901 |
|
517 |
self assert:( 'hello world' occurrencesOf:$0 ) == 0. |
|
1496 | 518 |
self assert:( 'hello world' occurrencesOf:$l ) == 3. |
519 |
self assert:( 'hello world' occurrencesOf:$d ) == 1. |
|
1418 | 520 |
|
521 |
"/ how about 0-bytes in between |
|
522 |
self assert:( #[0 0 1 0 0] asString occurrencesOf:(Character value:1) ) == 1. |
|
523 |
self assert:( #[0 0 1 0 0] asString occurrencesOf:(Character value:0) ) == 4. |
|
524 |
||
525 |
1 to:10 do:[:nA | |
|
1496 | 526 |
1 to:10 do:[:nB | |
527 |
s := (String new:nA withAll:$a),(String new:nB withAll:$b). |
|
528 |
self assert:(s occurrencesOf:$a) == nA. |
|
529 |
self assert:(s occurrencesOf:$b) == nB. |
|
530 |
] |
|
531 |
]. |
|
1418 | 532 |
|
533 |
s := String new:1024. |
|
534 |
s atAllPut:$a. |
|
535 |
s at:512 put:(Character space). |
|
536 |
self assert:(s occurrencesOf:(Character space)) == 1. |
|
537 |
self assert:(s occurrencesOf:$a) == 1023. |
|
538 |
||
539 |
s := String new:1024. |
|
540 |
s atAllPut:$a. |
|
541 |
1 to:1024 by:2 do:[:i | s at:i put:$b]. |
|
542 |
self assert:(s occurrencesOf:$a) == 512. |
|
543 |
self assert:(s occurrencesOf:$b) == 512. |
|
1421 | 544 |
|
1418 | 545 |
" |
1421 | 546 |
self new test43_occurrencesOf |
1418 | 547 |
" |
548 |
! |
|
549 |
||
571 | 550 |
test50_indexOf |
551 |
|s i| |
|
552 |
||
553 |
s := 'Some Sample Generators (74035660-d1f6-11df-9ab3-00ff7b08316c)'. |
|
554 |
1 to:s size do:[:start | |
|
1496 | 555 |
i := s indexOf:$- startingAt:start. |
556 |
self assert:(i == 0 or:[ i >= start]). |
|
571 | 557 |
]. |
1418 | 558 |
"/ 12345678901 |
559 |
self assert:( 'hello world' indexOf:$0 startingAt:1 ) == 0. |
|
1496 | 560 |
self assert:( 'hello world' indexOf:$l startingAt:1 ) == 3. |
561 |
self assert:( 'hello world' indexOf:$l startingAt:5 ) == 10. |
|
562 |
self assert:( 'hello world' indexOf:$d startingAt:5 ) == 11. |
|
1418 | 563 |
|
1426 | 564 |
"/ 12345678901 |
565 |
self assert:(('hello world' indexOf:$o startingAt:1) == 5). |
|
566 |
self assert:(('hello world' indexOf:$o startingAt:2) == 5). |
|
567 |
self assert:(('hello world' indexOf:$o startingAt:3) == 5). |
|
568 |
self assert:(('hello world' indexOf:$o startingAt:4) == 5). |
|
569 |
self assert:(('hello world' indexOf:$o startingAt:5) == 5). |
|
570 |
self assert:(('hello world' indexOf:$o startingAt:6) == 8). |
|
571 |
self assert:(('hello world' indexOf:$o startingAt:7) == 8). |
|
572 |
self assert:(('hello world' indexOf:$o startingAt:8) == 8). |
|
573 |
self assert:(('hello world' indexOf:$o startingAt:9) == 0). |
|
574 |
self assert:(('hello world' indexOf:$o startingAt:10) == 0). |
|
575 |
self assert:(('hello world' indexOf:$o startingAt:11) == 0). |
|
576 |
self assert:(('hello world' indexOf:$o startingAt:12) == 0). |
|
577 |
self assert:(('hello world' indexOf:$o startingAt:10000) == 0). |
|
578 |
||
1418 | 579 |
"/ how about 0-bytes in between |
580 |
self assert:( #[0 0 1 0 0] asString indexOf:(Character value:1) startingAt:1 ) == 3. |
|
581 |
self assert:( #[0 0 1 0 0] asString indexOf:(Character value:0) startingAt:3 ) == 4. |
|
582 |
self assert:( #[0 0 1 1 0] asString indexOf:(Character value:0) startingAt:3 ) == 5. |
|
583 |
self assert:( #[0 1 0 1 0] asString indexOf:(Character value:1) startingAt:3 ) == 4. |
|
584 |
||
585 |
s := '12345678901234b'. |
|
586 |
self assert:(s indexOf:$x) == 0. |
|
587 |
self assert:(s indexOf:$1) == 1. |
|
588 |
self assert:(s indexOf:$2) == 2. |
|
589 |
self assert:(s indexOf:$3) == 3. |
|
590 |
self assert:(s indexOf:$4) == 4. |
|
591 |
self assert:(s indexOf:$5) == 5. |
|
592 |
self assert:(s indexOf:$0) == 10. |
|
593 |
self assert:(s indexOf:$b) == 15. |
|
594 |
||
595 |
s := ''. |
|
596 |
self assert:(s indexOf:$1) == 0. |
|
597 |
s := '1'. |
|
598 |
self assert:(s indexOf:$1) == 1. |
|
599 |
self assert:(s indexOf:$2) == 0. |
|
600 |
s := '12'. |
|
601 |
self assert:(s indexOf:$1) == 1. |
|
602 |
self assert:(s indexOf:$2) == 2. |
|
603 |
self assert:(s indexOf:$3) == 0. |
|
604 |
s := '123'. |
|
605 |
self assert:(s indexOf:$1) == 1. |
|
606 |
self assert:(s indexOf:$2) == 2. |
|
607 |
self assert:(s indexOf:$3) == 3. |
|
608 |
self assert:(s indexOf:$4) == 0. |
|
609 |
s := '1234'. |
|
610 |
self assert:(s indexOf:$1) == 1. |
|
611 |
self assert:(s indexOf:$2) == 2. |
|
612 |
self assert:(s indexOf:$3) == 3. |
|
613 |
self assert:(s indexOf:$4) == 4. |
|
614 |
self assert:(s indexOf:$5) == 0. |
|
615 |
s := '12345'. |
|
616 |
self assert:(s indexOf:$1) == 1. |
|
617 |
self assert:(s indexOf:$2) == 2. |
|
618 |
self assert:(s indexOf:$3) == 3. |
|
619 |
self assert:(s indexOf:$4) == 4. |
|
620 |
self assert:(s indexOf:$5) == 5. |
|
621 |
self assert:(s indexOf:$6) == 0. |
|
622 |
s := '123456'. |
|
623 |
self assert:(s indexOf:$1) == 1. |
|
624 |
self assert:(s indexOf:$2) == 2. |
|
625 |
self assert:(s indexOf:$3) == 3. |
|
626 |
self assert:(s indexOf:$4) == 4. |
|
627 |
self assert:(s indexOf:$5) == 5. |
|
628 |
self assert:(s indexOf:$6) == 6. |
|
629 |
self assert:(s indexOf:$7) == 0. |
|
630 |
s := '1234567'. |
|
631 |
self assert:(s indexOf:$1) == 1. |
|
632 |
self assert:(s indexOf:$2) == 2. |
|
633 |
self assert:(s indexOf:$3) == 3. |
|
634 |
self assert:(s indexOf:$4) == 4. |
|
635 |
self assert:(s indexOf:$5) == 5. |
|
636 |
self assert:(s indexOf:$6) == 6. |
|
637 |
self assert:(s indexOf:$7) == 7. |
|
638 |
self assert:(s indexOf:$8) == 0. |
|
639 |
s := '12345678'. |
|
640 |
self assert:(s indexOf:$1) == 1. |
|
641 |
self assert:(s indexOf:$2) == 2. |
|
642 |
self assert:(s indexOf:$3) == 3. |
|
643 |
self assert:(s indexOf:$4) == 4. |
|
644 |
self assert:(s indexOf:$5) == 5. |
|
645 |
self assert:(s indexOf:$6) == 6. |
|
646 |
self assert:(s indexOf:$7) == 7. |
|
647 |
self assert:(s indexOf:$8) == 8. |
|
648 |
self assert:(s indexOf:$9) == 0. |
|
649 |
s := '123456789'. |
|
650 |
self assert:(s indexOf:$1) == 1. |
|
651 |
self assert:(s indexOf:$2) == 2. |
|
652 |
self assert:(s indexOf:$3) == 3. |
|
653 |
self assert:(s indexOf:$4) == 4. |
|
654 |
self assert:(s indexOf:$5) == 5. |
|
655 |
self assert:(s indexOf:$6) == 6. |
|
656 |
self assert:(s indexOf:$7) == 7. |
|
657 |
self assert:(s indexOf:$8) == 8. |
|
658 |
self assert:(s indexOf:$9) == 9. |
|
659 |
||
660 |
self assert:(s indexOf:$0) == 0. |
|
661 |
self assert:(s indexOf:$b) == 0. |
|
662 |
||
663 |
s := String new:1024. |
|
664 |
s atAllPut:$a. |
|
665 |
s at:512 put:(Character space). |
|
666 |
self assert:(s indexOf:(Character space)) == 512. |
|
667 |
self assert:(s indexOf:(Character space) startingAt:1) == 512. |
|
668 |
self assert:(s indexOf:(Character space) startingAt:2) == 512. |
|
669 |
self assert:(s indexOf:(Character space) startingAt:3) == 512. |
|
670 |
self assert:(s indexOf:(Character space) startingAt:4) == 512. |
|
671 |
self assert:(s indexOf:(Character space) startingAt:5) == 512. |
|
672 |
self assert:(s indexOf:(Character space) startingAt:6) == 512. |
|
673 |
self assert:(s indexOf:(Character space) startingAt:7) == 512. |
|
674 |
self assert:(s indexOf:(Character space) startingAt:8) == 512. |
|
675 |
self assert:(s indexOf:(Character space) startingAt:9) == 512. |
|
676 |
self assert:(s indexOf:(Character space) startingAt:511) == 512. |
|
677 |
self assert:(s indexOf:(Character space) startingAt:512) == 512. |
|
678 |
self assert:(s indexOf:(Character space) startingAt:513) == 0. |
|
571 | 679 |
|
680 |
" |
|
681 |
self new test50_indexOf |
|
682 |
" |
|
683 |
||
684 |
"Created: / 29-10-2010 / 14:58:21 / cg" |
|
751
8c9ff6c5efe2
Added string hashing tests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
702
diff
changeset
|
685 |
! |
8c9ff6c5efe2
Added string hashing tests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
702
diff
changeset
|
686 |
|
1471
f860709d1a2b
Added test for big #68: String>>indexOf:startingAt: broken under Windows/ MINGW64
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1470
diff
changeset
|
687 |
test51_indexOf |
f860709d1a2b
Added test for big #68: String>>indexOf:startingAt: broken under Windows/ MINGW64
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1470
diff
changeset
|
688 |
" |
f860709d1a2b
Added test for big #68: String>>indexOf:startingAt: broken under Windows/ MINGW64
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1470
diff
changeset
|
689 |
Tests for bug #68: String>>indexOf:startingAt: broken under Windows/ MINGW64 |
f860709d1a2b
Added test for big #68: String>>indexOf:startingAt: broken under Windows/ MINGW64
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1470
diff
changeset
|
690 |
https://swing.fit.cvut.cz/projects/stx-jv/ticket/68 |
f860709d1a2b
Added test for big #68: String>>indexOf:startingAt: broken under Windows/ MINGW64
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1470
diff
changeset
|
691 |
" |
f860709d1a2b
Added test for big #68: String>>indexOf:startingAt: broken under Windows/ MINGW64
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1470
diff
changeset
|
692 |
self assert: ('1234(xxxx' indexOf: $( startingAt: 1) == 5. |
f860709d1a2b
Added test for big #68: String>>indexOf:startingAt: broken under Windows/ MINGW64
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1470
diff
changeset
|
693 |
|
f860709d1a2b
Added test for big #68: String>>indexOf:startingAt: broken under Windows/ MINGW64
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1470
diff
changeset
|
694 |
"Created: / 23-11-2015 / 21:39:04 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
f860709d1a2b
Added test for big #68: String>>indexOf:startingAt: broken under Windows/ MINGW64
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1470
diff
changeset
|
695 |
! |
f860709d1a2b
Added test for big #68: String>>indexOf:startingAt: broken under Windows/ MINGW64
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1470
diff
changeset
|
696 |
|
1373 | 697 |
test51_substrings |
698 |
self assert:('aaa/bbb/ccc' subStrings:'/') asArray = #('aaa' 'bbb' 'ccc'). |
|
699 |
self assert:(('aaa/bbb/ccc' subStrings:'/') asStringWith:'/') = 'aaa/bbb/ccc'. |
|
700 |
||
1385 | 701 |
"/ self assert:('/aaa/bbb/ccc' subStrings:'/') asArray = #('' 'aaa' 'bbb' 'ccc'). |
702 |
"/ self assert:(('/aaa/bbb/ccc' subStrings:'/') asStringWith:'/') = '/aaa/bbb/ccc'. |
|
703 |
"/ |
|
704 |
"/ self assert:('aaa/bbb/ccc/' subStrings:'/') asArray = #('aaa' 'bbb' 'ccc' '' ). |
|
705 |
"/ self assert:(('aaa/bbb/ccc/' subStrings:'/') asStringWith:'/') = '/aaa/bbb/ccc/'. |
|
706 |
"/ |
|
707 |
"/ self assert:('/aaa/bbb/ccc/' subStrings:'/') asArray = #('' 'aaa' 'bbb' 'ccc' ''). |
|
708 |
"/ self assert:(('/aaa/bbb/ccc/' subStrings:'/') asStringWith:'/') = '/aaa/bbb/ccc'' '. |
|
709 |
"/ |
|
710 |
"/ self assert:('//aaa/bbb/ccc' subStrings:'/') asArray = #('' '' 'aaa' 'bbb' 'ccc'). |
|
711 |
"/ self assert:(('//aaa/bbb/ccc' subStrings:'/') asStringWith:'/') = '//aaa/bbb/ccc'. |
|
1373 | 712 |
|
713 |
" |
|
714 |
self new test51_substrings |
|
715 |
" |
|
716 |
! |
|
717 |
||
1420 | 718 |
test52_indexOfSeparator |
1426 | 719 |
|j s| |
1420 | 720 |
|
721 |
self assert:('' indexOfSeparator) == 0. |
|
722 |
1 to:20 do:[:n | |
|
1496 | 723 |
s := (String new:n withAll:$a). |
724 |
1 to:20 do:[:start | |
|
725 |
self assert:(s indexOfSeparatorStartingAt:start) == 0. |
|
726 |
]. |
|
727 |
]. |
|
1420 | 728 |
1 to:20 do:[:n | |
1496 | 729 |
s := (String new:n withAll:$a),' '. |
730 |
1 to:n do:[:start | |
|
731 |
self assert:(s indexOfSeparatorStartingAt:start) == (n+1). |
|
732 |
]. |
|
733 |
]. |
|
734 |
||
735 |
{ |
|
736 |
Character space . |
|
737 |
Character tab . |
|
738 |
Character return . |
|
739 |
Character lf . |
|
1420 | 740 |
} do:[:sep | |
1496 | 741 |
1 to:20 do:[:na | |
742 |
1 to:20 do:[:nb | |
|
743 |
s := (String new:na withAll:$a),sep,(String new:na withAll:$a). |
|
744 |
1 to:na do:[:start | |
|
745 |
self assert:(s indexOfSeparatorStartingAt:start) == (na+1). |
|
746 |
] |
|
747 |
] |
|
748 |
]. |
|
1420 | 749 |
]. |
1496 | 750 |
|
751 |
{ |
|
752 |
Character esc . |
|
753 |
Character null . |
|
754 |
$a . |
|
1420 | 755 |
} do:[:nonSep | |
1496 | 756 |
1 to:20 do:[:na | |
757 |
1 to:20 do:[:nb | |
|
758 |
s := (String new:na withAll:$a),nonSep,(String new:na withAll:$a). |
|
759 |
1 to:20 do:[:start | |
|
760 |
self assert:(s indexOfSeparatorStartingAt:start) == 0. |
|
761 |
] |
|
762 |
] |
|
763 |
]. |
|
1420 | 764 |
]. |
765 |
||
1426 | 766 |
s := String new:1000 withAll:$a. |
767 |
self assert:(s indexOfSeparatorStartingAt:1) == 0. |
|
768 |
400 to: 417 do:[:i | |
|
1496 | 769 |
s := String new:1000 withAll:$a. |
770 |
s at:i put:(Character space). |
|
771 |
self assert:(s indexOfSeparatorStartingAt:1) == i. |
|
1426 | 772 |
|
1496 | 773 |
s := String new:1000 withAll:$a. |
774 |
s at:i put:(Character return). |
|
775 |
self assert:(s indexOfSeparatorStartingAt:1) == i. |
|
776 |
]. |
|
1426 | 777 |
|
778 |
"/ 12345678901 |
|
779 |
j := 'hello world' indexOfSeparatorStartingAt:1. |
|
780 |
self assert:(j == 6). |
|
781 |
j := 'hello world ' indexOfSeparatorStartingAt:2. |
|
782 |
self assert:(j == 6). |
|
783 |
j := 'hello world ' indexOfSeparatorStartingAt:3. |
|
1496 | 784 |
self assert:(j == 6). |
1426 | 785 |
j := 'hello world ' indexOfSeparatorStartingAt:4. |
1496 | 786 |
self assert:(j == 6). |
1426 | 787 |
j := 'hello world ' indexOfSeparatorStartingAt:5. |
788 |
self assert:(j == 6). |
|
789 |
j := 'hello world ' indexOfSeparatorStartingAt:6. |
|
790 |
self assert:(j == 6). |
|
791 |
j := 'hello world ' indexOfSeparatorStartingAt:7. |
|
792 |
self assert:(j == 12). |
|
793 |
j := 'hello world ' indexOfSeparatorStartingAt:8. |
|
794 |
self assert:(j == 12). |
|
795 |
j := 'hello world ' indexOfSeparatorStartingAt:9. |
|
1496 | 796 |
self assert:(j == 12). |
1426 | 797 |
j := 'hello world ' indexOfSeparatorStartingAt:10. |
1496 | 798 |
self assert:(j == 12). |
1426 | 799 |
j := 'hello world ' indexOfSeparatorStartingAt:11. |
800 |
self assert:(j == 12). |
|
801 |
j := 'hello world ' indexOfSeparatorStartingAt:12. |
|
802 |
self assert:(j == 12). |
|
803 |
j := 'hello world' indexOfSeparatorStartingAt:12. |
|
1496 | 804 |
self assert:(j == 0). |
1426 | 805 |
j := 'hello world ' indexOfSeparatorStartingAt:13. |
806 |
self assert:(j == 0). |
|
807 |
j := 'hello world ' indexOfSeparatorStartingAt:10000. |
|
1496 | 808 |
self assert:(j == 0). |
809 |
||
1420 | 810 |
" |
811 |
self new test52_indexOfSeparator |
|
812 |
" |
|
813 |
! |
|
814 |
||
815 |
test54_occurrencesOf |
|
816 |
|s| |
|
817 |
||
818 |
self assert:('' occurrencesOf:$a) == 0. |
|
819 |
1 to:20 do:[:n | |
|
1496 | 820 |
s := (String new:n withAll:$a). |
821 |
self assert:(s occurrencesOf:$a) == n. |
|
822 |
]. |
|
1420 | 823 |
1 to:20 do:[:na | |
1496 | 824 |
1 to:20 do:[:nb | |
825 |
s := (String new:na withAll:$a),(String new:nb withAll:$b). |
|
826 |
self assert:(s occurrencesOf:$a) == na. |
|
827 |
]. |
|
828 |
]. |
|
1420 | 829 |
1 to:40 do:[:n | |
1496 | 830 |
s := String new:n withAll:$a. |
831 |
1 to:n by:2 do:[:n | |
|
832 |
s at:n put:$b. |
|
833 |
]. |
|
834 |
self assert:(s occurrencesOf:$a) == (n // 2). |
|
835 |
]. |
|
836 |
||
1420 | 837 |
s := String new:1000 withAll:$a. |
838 |
self assert:(s occurrencesOf:$a) == 1000. |
|
839 |
1 to:1000 do:[:i | |
|
1496 | 840 |
s at:i put:$b. |
841 |
self assert:(s occurrencesOf:$a) == (1000-i). |
|
842 |
self assert:(s occurrencesOf:$b) == i. |
|
1420 | 843 |
]. |
1496 | 844 |
|
1420 | 845 |
" |
846 |
self new test54_occurrencesOf |
|
847 |
" |
|
848 |
! |
|
849 |
||
751
8c9ff6c5efe2
Added string hashing tests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
702
diff
changeset
|
850 |
test60_hash |
8c9ff6c5efe2
Added string hashing tests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
702
diff
changeset
|
851 |
" |
8c9ff6c5efe2
Added string hashing tests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
702
diff
changeset
|
852 |
As of 2013-01-09 for strings of size 7 String & Unicode16String hash |
8c9ff6c5efe2
Added string hashing tests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
702
diff
changeset
|
853 |
returned different values. This test checks this |
8c9ff6c5efe2
Added string hashing tests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
702
diff
changeset
|
854 |
" |
8c9ff6c5efe2
Added string hashing tests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
702
diff
changeset
|
855 |
|
753
81af28f807cf
class: RegressionTests::StringTests
Stefan Vogel <sv@exept.de>
parents:
752
diff
changeset
|
856 |
| tester | |
751
8c9ff6c5efe2
Added string hashing tests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
702
diff
changeset
|
857 |
|
753
81af28f807cf
class: RegressionTests::StringTests
Stefan Vogel <sv@exept.de>
parents:
752
diff
changeset
|
858 |
tester := [:s| |
1485 | 859 |
|sHash u16Hash u32Hash| |
1385 | 860 |
|
1485 | 861 |
sHash := s hash. |
862 |
u16Hash := s asUnicode16String hash. |
|
863 |
u32Hash := s asUnicode32String hash. |
|
1385 | 864 |
|
1485 | 865 |
self assert: sHash == u16Hash |
1486 | 866 |
description: ('String and Unicode16String hashes differ on "%1" (%2)' |
867 |
bindWith:s with:s class name). |
|
1485 | 868 |
self assert: sHash == u32Hash |
1486 | 869 |
description: ('String and Unicode32String hashes differ on "%1" (%2)' |
870 |
bindWith:s with:s class name) |
|
751
8c9ff6c5efe2
Added string hashing tests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
702
diff
changeset
|
871 |
]. |
8c9ff6c5efe2
Added string hashing tests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
702
diff
changeset
|
872 |
|
753
81af28f807cf
class: RegressionTests::StringTests
Stefan Vogel <sv@exept.de>
parents:
752
diff
changeset
|
873 |
tester value:'a'. |
1385 | 874 |
tester value:'12345678901234'. |
875 |
tester value:'1234567890123'. |
|
876 |
tester value:'123456789012'. |
|
877 |
tester value:'12345678901'. |
|
878 |
tester value:'1234567890'. |
|
879 |
tester value:'123456789'. |
|
753
81af28f807cf
class: RegressionTests::StringTests
Stefan Vogel <sv@exept.de>
parents:
752
diff
changeset
|
880 |
tester value:'12345678'. |
81af28f807cf
class: RegressionTests::StringTests
Stefan Vogel <sv@exept.de>
parents:
752
diff
changeset
|
881 |
tester value:'1234567'. |
81af28f807cf
class: RegressionTests::StringTests
Stefan Vogel <sv@exept.de>
parents:
752
diff
changeset
|
882 |
tester value:'123456'. |
1385 | 883 |
tester value:'12345'. |
884 |
tester value:'1234'. |
|
885 |
tester value:'123'. |
|
886 |
tester value:'12'. |
|
753
81af28f807cf
class: RegressionTests::StringTests
Stefan Vogel <sv@exept.de>
parents:
752
diff
changeset
|
887 |
tester value:'boolean'. |
751
8c9ff6c5efe2
Added string hashing tests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
702
diff
changeset
|
888 |
|
1417 | 889 |
"/ strings with 0-elements |
890 |
tester value:('' copyWith:Character null). |
|
891 |
tester value:('1' copyWith:Character null). |
|
892 |
tester value:('12' copyWith:Character null). |
|
893 |
tester value:('123' copyWith:Character null). |
|
894 |
tester value:('1234' copyWith:Character null). |
|
895 |
tester value:('12345' copyWith:Character null). |
|
896 |
tester value:('123456' copyWith:Character null). |
|
897 |
tester value:('1234567' copyWith:Character null). |
|
898 |
tester value:('12345678' copyWith:Character null). |
|
899 |
tester value:('123456789' copyWith:Character null). |
|
1419 | 900 |
|
901 |
tester value:('' copyWith:Character null),'123'. |
|
902 |
tester value:('1' copyWith:Character null),'123'. |
|
903 |
tester value:('12' copyWith:Character null),'123'. |
|
904 |
tester value:('123' copyWith:Character null),'123'. |
|
905 |
tester value:('1234' copyWith:Character null),'123'. |
|
906 |
tester value:('12345' copyWith:Character null),'123'. |
|
907 |
tester value:('123456' copyWith:Character null),'123'. |
|
908 |
tester value:('1234567' copyWith:Character null),'123'. |
|
909 |
tester value:('12345678' copyWith:Character null),'123'. |
|
910 |
tester value:('123456789' copyWith:Character null),'123'. |
|
1496 | 911 |
|
1419 | 912 |
"/ String allInstancesDo:[:each| tester value:each]. |
753
81af28f807cf
class: RegressionTests::StringTests
Stefan Vogel <sv@exept.de>
parents:
752
diff
changeset
|
913 |
Symbol allInstancesDo:[:each| tester value:each]. |
751
8c9ff6c5efe2
Added string hashing tests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
702
diff
changeset
|
914 |
|
8c9ff6c5efe2
Added string hashing tests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
702
diff
changeset
|
915 |
"Created: / 09-01-2013 / 10:58:22 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
962
2fca937dc59b
class: RegressionTests::StringTests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
874
diff
changeset
|
916 |
! |
2fca937dc59b
class: RegressionTests::StringTests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
874
diff
changeset
|
917 |
|
1426 | 918 |
test65_concatenation |
919 |
|strA strB| |
|
920 |
||
1496 | 921 |
0 to:32 do:[:szA | |
922 |
0 to:32 do:[:szB | |
|
923 |
|szAB| |
|
1426 | 924 |
|
1496 | 925 |
strA := String new:szA withAll:$a. |
926 |
strB := String new:szB withAll:$b. |
|
927 |
szAB := szA + szB. |
|
928 |
self assert:(szA = strA size). |
|
929 |
self assert:(szB = strB size). |
|
930 |
10000 timesRepeat:[ |
|
931 |
|strAB| |
|
1426 | 932 |
|
1496 | 933 |
strAB := strA , strB. |
1426 | 934 |
|
1496 | 935 |
self assert:(szAB == strAB size). |
936 |
] |
|
937 |
] |
|
1426 | 938 |
]. |
939 |
||
940 |
strA := strB := ''. |
|
941 |
self assert: ((strA , strB) = ''). |
|
942 |
self assert: ((strA , strA) = ''). |
|
943 |
strA := 'a'. |
|
1496 | 944 |
self assert: ((strA , strA) = 'aa'). |
1426 | 945 |
self assert: ((strA , strB) = 'a'). |
946 |
strA := ''. |
|
947 |
strB := 'b'. |
|
1496 | 948 |
self assert: ((strA , strB) = 'b'). |
1426 | 949 |
strA := 'b'. |
950 |
strB := 'a'. |
|
1496 | 951 |
self assert: ((strB , strA) = 'ab'). |
1426 | 952 |
" |
953 |
self new test65_concatenation |
|
954 |
" |
|
955 |
! |
|
956 |
||
957 |
test66_replace |
|
958 |
|strA| |
|
959 |
||
960 |
1 to:64 do:[:szA | |
|
1496 | 961 |
strA := String new:szA withAll:$a. |
962 |
1 to:szA do:[:idx | |
|
963 |
strA at:idx put:$*. |
|
1426 | 964 |
|
1496 | 965 |
strA replaceAll:$* with:$#. |
1426 | 966 |
|
1496 | 967 |
self assert:(strA at:idx) = $#. |
968 |
self assert:(strA occurrencesOf:$#) = idx. |
|
969 |
self assert:(strA count:[:ch | ch = $#]) = idx. |
|
970 |
self assert:(strA occurrencesOf:$*) = 0. |
|
971 |
self assert:(strA count:[:ch | ch = $*]) = 0. |
|
972 |
self assert:(strA includes:$#). |
|
973 |
self assert:(strA includes:$*) not. |
|
974 |
] |
|
1426 | 975 |
] |
976 |
||
977 |
" |
|
978 |
self new test66_replace |
|
979 |
" |
|
980 |
! |
|
981 |
||
982 |
test67_concatenationAnd |
|
983 |
|strA strB strC| |
|
984 |
||
1496 | 985 |
0 to:32 do:[:szA | |
986 |
0 to:32 do:[:szB | |
|
987 |
0 to:32 do:[:szC | |
|
988 |
|szABC| |
|
989 |
strA := String new:szA withAll:$a. |
|
990 |
strB := String new:szB withAll:$b. |
|
991 |
strC := String new:szC withAll:$c. |
|
1426 | 992 |
|
1496 | 993 |
szABC := szA + szB + szC. |
994 |
self assert:(szA = strA size). |
|
995 |
self assert:(szB = strB size). |
|
996 |
self assert:(szC = strC size). |
|
1426 | 997 |
|
1496 | 998 |
300 timesRepeat:[ |
999 |
|strABC| |
|
1426 | 1000 |
|
1496 | 1001 |
strABC := strA concatenate:strB and:strC. |
1426 | 1002 |
|
1496 | 1003 |
self assert:(szABC == strABC size). |
1004 |
] |
|
1005 |
] |
|
1006 |
] |
|
1426 | 1007 |
]. |
1008 |
strA := strB := strC := ''. |
|
1009 |
self assert: ((strA concatenate:strB and:strC) = ''). |
|
1010 |
strA := 'a'. |
|
1011 |
self assert: ((strA concatenate:strB and:strC) = 'a'). |
|
1012 |
strA := ''. |
|
1013 |
strB := 'b'. |
|
1496 | 1014 |
self assert: ((strA concatenate:strB and:strC) = 'b'). |
1426 | 1015 |
strB := ''. |
1016 |
strC := 'c'. |
|
1496 | 1017 |
self assert: ((strA concatenate:strB and:strC) = 'c'). |
1426 | 1018 |
strA := 'c'. |
1019 |
strB := 'b'. |
|
1020 |
strC := 'a'. |
|
1496 | 1021 |
self assert: ((strC concatenate:strB and:strA) = 'abc'). |
1426 | 1022 |
" |
1023 |
self new test67_concatenationAnd |
|
1024 |
" |
|
1025 |
! |
|
1026 |
||
1027 |
test68_concatenationAndAnd |
|
1028 |
|strA strB strC strD| |
|
1029 |
||
1496 | 1030 |
0 to:32 do:[:szA | |
1031 |
strA := String new:szA withAll:$a. |
|
1032 |
self assert:(szA = strA size). |
|
1033 |
0 to:32 do:[:szB | |
|
1034 |
strB := String new:szB withAll:$b. |
|
1035 |
self assert:(szB = strB size). |
|
1036 |
0 to:32 do:[:szC | |
|
1037 |
strC := String new:szC withAll:$c. |
|
1038 |
self assert:(szC = strC size). |
|
1039 |
0 to:32 do:[:szD | |
|
1040 |
|szABCD| |
|
1041 |
strD := String new:szD withAll:$d. |
|
1426 | 1042 |
|
1496 | 1043 |
szABCD := szA + szB + szC + szD. |
1426 | 1044 |
|
1496 | 1045 |
self assert:(szD = strD size). |
1426 | 1046 |
|
1496 | 1047 |
5 timesRepeat:[ |
1048 |
|strABCD| |
|
1426 | 1049 |
|
1496 | 1050 |
strABCD := strA concatenate:strB and:strC and:strD. |
1426 | 1051 |
|
1496 | 1052 |
self assert:(szABCD == strABCD size). |
1053 |
] |
|
1054 |
] |
|
1055 |
] |
|
1056 |
] |
|
1426 | 1057 |
]. |
1058 |
||
1059 |
strA := strB := strC := strD := ''. |
|
1060 |
self assert: ((strA concatenate:strB and:strC and:strD) = ''). |
|
1061 |
strA := 'a'. |
|
1062 |
self assert: ((strA concatenate:strB and:strC and:strD) = 'a'). |
|
1063 |
strA := ''. |
|
1064 |
strB := 'b'. |
|
1496 | 1065 |
self assert: ((strA concatenate:strB and:strC and:strD) = 'b'). |
1426 | 1066 |
strB := ''. |
1067 |
strC := 'c'. |
|
1496 | 1068 |
self assert: ((strA concatenate:strB and:strC and:strD) = 'c'). |
1426 | 1069 |
strC := ''. |
1070 |
strD := 'd'. |
|
1496 | 1071 |
self assert: ((strA concatenate:strB and:strC and:strD) = 'd'). |
1426 | 1072 |
strA := 'd'. |
1073 |
strB := 'c'. |
|
1074 |
strC := 'b'. |
|
1496 | 1075 |
strD := 'a'. |
1076 |
self assert: ((strD concatenate:strC and:strB and:strA) = 'abcd'). |
|
1426 | 1077 |
" |
1078 |
self new test68_concatenationAndAnd |
|
1079 |
" |
|
1080 |
! |
|
1081 |
||
962
2fca937dc59b
class: RegressionTests::StringTests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
874
diff
changeset
|
1082 |
test70_storeString |
2fca937dc59b
class: RegressionTests::StringTests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
874
diff
changeset
|
1083 |
|
2fca937dc59b
class: RegressionTests::StringTests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
874
diff
changeset
|
1084 |
self assert: 'AAA' storeString = '''AAA'''. |
2fca937dc59b
class: RegressionTests::StringTests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
874
diff
changeset
|
1085 |
self assert: 'A''A''A' storeString = '''A''''A''''A'''. |
2fca937dc59b
class: RegressionTests::StringTests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
874
diff
changeset
|
1086 |
|
2fca937dc59b
class: RegressionTests::StringTests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
874
diff
changeset
|
1087 |
self assert: 'AAA' asImmutableString storeString = '''AAA'''. |
2fca937dc59b
class: RegressionTests::StringTests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
874
diff
changeset
|
1088 |
self assert: 'A''A''A' asImmutableString storeString = '''A''''A''''A'''. |
2fca937dc59b
class: RegressionTests::StringTests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
874
diff
changeset
|
1089 |
|
2fca937dc59b
class: RegressionTests::StringTests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
874
diff
changeset
|
1090 |
"Created: / 14-07-2013 / 19:17:33 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
1103
373c0f5e539d
class: RegressionTests::StringTests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1060
diff
changeset
|
1091 |
! |
373c0f5e539d
class: RegressionTests::StringTests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1060
diff
changeset
|
1092 |
|
373c0f5e539d
class: RegressionTests::StringTests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1060
diff
changeset
|
1093 |
test80_copyReplaceAll |
373c0f5e539d
class: RegressionTests::StringTests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1060
diff
changeset
|
1094 |
|
373c0f5e539d
class: RegressionTests::StringTests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1060
diff
changeset
|
1095 |
| orig copy | |
373c0f5e539d
class: RegressionTests::StringTests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1060
diff
changeset
|
1096 |
|
373c0f5e539d
class: RegressionTests::StringTests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1060
diff
changeset
|
1097 |
orig := 'AAA' copy. "/ In case literals are immutable... |
373c0f5e539d
class: RegressionTests::StringTests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1060
diff
changeset
|
1098 |
self assert: orig = 'AAA'. |
373c0f5e539d
class: RegressionTests::StringTests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1060
diff
changeset
|
1099 |
|
373c0f5e539d
class: RegressionTests::StringTests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1060
diff
changeset
|
1100 |
copy := orig copyReplaceAll: $A with: $X. |
373c0f5e539d
class: RegressionTests::StringTests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1060
diff
changeset
|
1101 |
self assert: copy = 'XXX'. |
373c0f5e539d
class: RegressionTests::StringTests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1060
diff
changeset
|
1102 |
self assert: orig = 'AAA'. |
373c0f5e539d
class: RegressionTests::StringTests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1060
diff
changeset
|
1103 |
|
373c0f5e539d
class: RegressionTests::StringTests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1060
diff
changeset
|
1104 |
orig := 'AAA' asImmutableString. |
373c0f5e539d
class: RegressionTests::StringTests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1060
diff
changeset
|
1105 |
self assert: orig = 'AAA'. |
373c0f5e539d
class: RegressionTests::StringTests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1060
diff
changeset
|
1106 |
|
373c0f5e539d
class: RegressionTests::StringTests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1060
diff
changeset
|
1107 |
copy := orig copyReplaceAll: $A with: $X. |
373c0f5e539d
class: RegressionTests::StringTests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1060
diff
changeset
|
1108 |
self assert: copy = 'XXX'. |
373c0f5e539d
class: RegressionTests::StringTests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1060
diff
changeset
|
1109 |
self assert: orig = 'AAA'. |
373c0f5e539d
class: RegressionTests::StringTests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1060
diff
changeset
|
1110 |
|
373c0f5e539d
class: RegressionTests::StringTests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1060
diff
changeset
|
1111 |
"Created: / 06-03-2014 / 15:10:19 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
1214
11cb005634cb
class: RegressionTests::StringTests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1103
diff
changeset
|
1112 |
! |
11cb005634cb
class: RegressionTests::StringTests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1103
diff
changeset
|
1113 |
|
1240
4b187f56458b
class: RegressionTests::StringTests
Claus Gittinger <cg@exept.de>
parents:
1214
diff
changeset
|
1114 |
test81_filling |
4b187f56458b
class: RegressionTests::StringTests
Claus Gittinger <cg@exept.de>
parents:
1214
diff
changeset
|
1115 |
|
4b187f56458b
class: RegressionTests::StringTests
Claus Gittinger <cg@exept.de>
parents:
1214
diff
changeset
|
1116 |
| str | |
4b187f56458b
class: RegressionTests::StringTests
Claus Gittinger <cg@exept.de>
parents:
1214
diff
changeset
|
1117 |
|
4b187f56458b
class: RegressionTests::StringTests
Claus Gittinger <cg@exept.de>
parents:
1214
diff
changeset
|
1118 |
str := 'AAA' copy. "/ In case literals are immutable... |
4b187f56458b
class: RegressionTests::StringTests
Claus Gittinger <cg@exept.de>
parents:
1214
diff
changeset
|
1119 |
|
4b187f56458b
class: RegressionTests::StringTests
Claus Gittinger <cg@exept.de>
parents:
1214
diff
changeset
|
1120 |
str atAllPut:$B. |
4b187f56458b
class: RegressionTests::StringTests
Claus Gittinger <cg@exept.de>
parents:
1214
diff
changeset
|
1121 |
self assert: str = 'BBB'. |
4b187f56458b
class: RegressionTests::StringTests
Claus Gittinger <cg@exept.de>
parents:
1214
diff
changeset
|
1122 |
|
4b187f56458b
class: RegressionTests::StringTests
Claus Gittinger <cg@exept.de>
parents:
1214
diff
changeset
|
1123 |
str from:1 to:0 put:$C. |
4b187f56458b
class: RegressionTests::StringTests
Claus Gittinger <cg@exept.de>
parents:
1214
diff
changeset
|
1124 |
self assert: str = 'BBB'. |
4b187f56458b
class: RegressionTests::StringTests
Claus Gittinger <cg@exept.de>
parents:
1214
diff
changeset
|
1125 |
|
4b187f56458b
class: RegressionTests::StringTests
Claus Gittinger <cg@exept.de>
parents:
1214
diff
changeset
|
1126 |
str from:1 to:1 put:$D. |
4b187f56458b
class: RegressionTests::StringTests
Claus Gittinger <cg@exept.de>
parents:
1214
diff
changeset
|
1127 |
self assert: str = 'DBB'. |
4b187f56458b
class: RegressionTests::StringTests
Claus Gittinger <cg@exept.de>
parents:
1214
diff
changeset
|
1128 |
|
4b187f56458b
class: RegressionTests::StringTests
Claus Gittinger <cg@exept.de>
parents:
1214
diff
changeset
|
1129 |
str from:1 to:2 put:$E. |
4b187f56458b
class: RegressionTests::StringTests
Claus Gittinger <cg@exept.de>
parents:
1214
diff
changeset
|
1130 |
self assert: str = 'EEB'. |
4b187f56458b
class: RegressionTests::StringTests
Claus Gittinger <cg@exept.de>
parents:
1214
diff
changeset
|
1131 |
|
4b187f56458b
class: RegressionTests::StringTests
Claus Gittinger <cg@exept.de>
parents:
1214
diff
changeset
|
1132 |
str from:1 to:3 put:$F. |
4b187f56458b
class: RegressionTests::StringTests
Claus Gittinger <cg@exept.de>
parents:
1214
diff
changeset
|
1133 |
self assert: str = 'FFF'. |
4b187f56458b
class: RegressionTests::StringTests
Claus Gittinger <cg@exept.de>
parents:
1214
diff
changeset
|
1134 |
|
4b187f56458b
class: RegressionTests::StringTests
Claus Gittinger <cg@exept.de>
parents:
1214
diff
changeset
|
1135 |
str from:1 to:0 put:$G. |
4b187f56458b
class: RegressionTests::StringTests
Claus Gittinger <cg@exept.de>
parents:
1214
diff
changeset
|
1136 |
self assert: str = 'FFF'. |
4b187f56458b
class: RegressionTests::StringTests
Claus Gittinger <cg@exept.de>
parents:
1214
diff
changeset
|
1137 |
|
4b187f56458b
class: RegressionTests::StringTests
Claus Gittinger <cg@exept.de>
parents:
1214
diff
changeset
|
1138 |
str from:-1 to:-2 put:$G. |
4b187f56458b
class: RegressionTests::StringTests
Claus Gittinger <cg@exept.de>
parents:
1214
diff
changeset
|
1139 |
self assert: str = 'FFF'. |
4b187f56458b
class: RegressionTests::StringTests
Claus Gittinger <cg@exept.de>
parents:
1214
diff
changeset
|
1140 |
|
4b187f56458b
class: RegressionTests::StringTests
Claus Gittinger <cg@exept.de>
parents:
1214
diff
changeset
|
1141 |
self should:[ |
1421 | 1142 |
str from:-1 to:-1 put:$x |
1240
4b187f56458b
class: RegressionTests::StringTests
Claus Gittinger <cg@exept.de>
parents:
1214
diff
changeset
|
1143 |
] raise:SubscriptOutOfBoundsError. |
4b187f56458b
class: RegressionTests::StringTests
Claus Gittinger <cg@exept.de>
parents:
1214
diff
changeset
|
1144 |
self assert: str = 'FFF'. |
4b187f56458b
class: RegressionTests::StringTests
Claus Gittinger <cg@exept.de>
parents:
1214
diff
changeset
|
1145 |
|
4b187f56458b
class: RegressionTests::StringTests
Claus Gittinger <cg@exept.de>
parents:
1214
diff
changeset
|
1146 |
self should:[ |
1421 | 1147 |
str from:-1 to:1 put:$x |
1240
4b187f56458b
class: RegressionTests::StringTests
Claus Gittinger <cg@exept.de>
parents:
1214
diff
changeset
|
1148 |
] raise:SubscriptOutOfBoundsError. |
4b187f56458b
class: RegressionTests::StringTests
Claus Gittinger <cg@exept.de>
parents:
1214
diff
changeset
|
1149 |
self assert: str = 'FFF'. |
4b187f56458b
class: RegressionTests::StringTests
Claus Gittinger <cg@exept.de>
parents:
1214
diff
changeset
|
1150 |
! |
4b187f56458b
class: RegressionTests::StringTests
Claus Gittinger <cg@exept.de>
parents:
1214
diff
changeset
|
1151 |
|
1214
11cb005634cb
class: RegressionTests::StringTests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1103
diff
changeset
|
1152 |
test90_hash |
11cb005634cb
class: RegressionTests::StringTests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1103
diff
changeset
|
1153 |
| string8 string16 string32 | |
11cb005634cb
class: RegressionTests::StringTests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1103
diff
changeset
|
1154 |
|
11cb005634cb
class: RegressionTests::StringTests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1103
diff
changeset
|
1155 |
string8 := 'sun/nio/cs/UTF_8.class'. |
11cb005634cb
class: RegressionTests::StringTests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1103
diff
changeset
|
1156 |
string16 := string8 asUnicode16String. |
11cb005634cb
class: RegressionTests::StringTests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1103
diff
changeset
|
1157 |
string32 := string8 asUnicode16String. |
11cb005634cb
class: RegressionTests::StringTests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1103
diff
changeset
|
1158 |
|
11cb005634cb
class: RegressionTests::StringTests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1103
diff
changeset
|
1159 |
self assert: string8 hash == string16 hash. |
11cb005634cb
class: RegressionTests::StringTests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1103
diff
changeset
|
1160 |
self assert: string8 hash == string32 hash. |
11cb005634cb
class: RegressionTests::StringTests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1103
diff
changeset
|
1161 |
|
11cb005634cb
class: RegressionTests::StringTests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1103
diff
changeset
|
1162 |
"Created: / 09-10-2014 / 12:41:01 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
283 | 1163 |
! ! |
1164 |
||
1165 |
!StringTests class methodsFor:'documentation'! |
|
1166 |
||
1167 |
version |
|
1168 |
^ '$Header$' |
|
570 | 1169 |
! |
1170 |
||
1171 |
version_CVS |
|
1172 |
^ '$Header$' |
|
1471
f860709d1a2b
Added test for big #68: String>>indexOf:startingAt: broken under Windows/ MINGW64
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1470
diff
changeset
|
1173 |
! |
f860709d1a2b
Added test for big #68: String>>indexOf:startingAt: broken under Windows/ MINGW64
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1470
diff
changeset
|
1174 |
|
f860709d1a2b
Added test for big #68: String>>indexOf:startingAt: broken under Windows/ MINGW64
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1470
diff
changeset
|
1175 |
version_HG |
f860709d1a2b
Added test for big #68: String>>indexOf:startingAt: broken under Windows/ MINGW64
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1470
diff
changeset
|
1176 |
|
f860709d1a2b
Added test for big #68: String>>indexOf:startingAt: broken under Windows/ MINGW64
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1470
diff
changeset
|
1177 |
^ '$Changeset: <not expanded> $' |
283 | 1178 |
! ! |
752
ef9236c7271c
class: RegressionTests::StringTests
Stefan Vogel <sv@exept.de>
parents:
751
diff
changeset
|
1179 |