author | sr |
Wed, 18 Oct 2017 11:28:56 +0200 | |
changeset 1876 | dfc87bb5d4ec |
parent 1693 | 04a3687c829e |
child 1990 | add7e46a1fac |
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 |
|
1447 | 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 | |
|
1447 | 34 |
str := aStringClass new:l. |
35 |
str atAllPut:(Character space). |
|
36 |
self assert:( str isBlank ). |
|
284 | 37 |
|
1447 | 38 |
1 to:l do:[:pos | |
39 |
str at:pos put:$a. |
|
40 |
self assert:( str isBlank not ). |
|
41 |
str at:pos put:(Character space). |
|
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'). |
|
1447 | 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 | |
|
1447 | 152 |
|str| |
288 | 153 |
|
1447 | 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 |
|
1447 | 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 |
||
1693 | 205 |
test03_unicode16 |
206 |
|u s u2| |
|
207 |
||
208 |
u := 'hello' asUnicode16String. |
|
209 |
self assert:(u class == Unicode16String). |
|
210 |
self assert:(u size == 5). |
|
211 |
self assert:((u at:1) == $h). |
|
212 |
self assert:((u at:2) == $e). |
|
213 |
self assert:((u at:3) == $l). |
|
214 |
self assert:((u at:4) == $l). |
|
215 |
self assert:((u at:5) == $o). |
|
216 |
||
217 |
s := u asSingleByteString. |
|
218 |
self assert:(s class == String). |
|
219 |
self assert:(s size == 5). |
|
220 |
self assert:((s at:1) == $h). |
|
221 |
self assert:((s at:2) == $e). |
|
222 |
self assert:((s at:3) == $l). |
|
223 |
self assert:((s at:4) == $l). |
|
224 |
self assert:((s at:5) == $o). |
|
225 |
||
226 |
s := u asSingleByteStringIfPossible. |
|
227 |
self assert:(s class == String). |
|
228 |
self assert:(s size == 5). |
|
229 |
self assert:((s at:1) == $h). |
|
230 |
self assert:((s at:2) == $e). |
|
231 |
self assert:((s at:3) == $l). |
|
232 |
self assert:((s at:4) == $l). |
|
233 |
self assert:((s at:5) == $o). |
|
234 |
||
235 |
u2 := 'hello' asUnicode16String. |
|
236 |
u2 at:1 put:(Character codePoint:16r20AC). "/ euro character |
|
237 |
self assert:(u2 size == 5). |
|
238 |
self assert:((u2 at:1) = (Character codePoint:16r20AC)). |
|
239 |
self assert:((u2 at:2) == $e). |
|
240 |
self assert:((u2 at:3) == $l). |
|
241 |
self assert:((u2 at:4) == $l). |
|
242 |
self assert:((u2 at:5) == $o). |
|
243 |
||
244 |
s := u2 asSingleByteStringIfPossible. |
|
245 |
self assert:(s class == Unicode16String). |
|
246 |
self assert:(u2 == s). |
|
247 |
||
248 |
u := Unicode16String fromString:'hello'. |
|
249 |
self assert:(u class == Unicode16String). |
|
250 |
self assert:(u size == 5). |
|
251 |
self assert:((u at:1) == $h). |
|
252 |
self assert:((u at:2) == $e). |
|
253 |
self assert:((u at:3) == $l). |
|
254 |
self assert:((u at:4) == $l). |
|
255 |
self assert:((u at:5) == $o). |
|
256 |
||
257 |
u replaceFrom:1 to:5 with:'abcde' startingAt:1. |
|
258 |
self assert:(u class == Unicode16String). |
|
259 |
self assert:(u size == 5). |
|
260 |
self assert:((u at:1) == $a). |
|
261 |
self assert:((u at:2) == $b). |
|
262 |
self assert:((u at:3) == $c). |
|
263 |
self assert:((u at:4) == $d). |
|
264 |
self assert:((u at:5) == $e). |
|
265 |
||
266 |
" |
|
267 |
self new test03_unicode16 |
|
268 |
" |
|
269 |
||
270 |
"Created: / 30-08-2017 / 23:51:07 / cg" |
|
271 |
! |
|
272 |
||
284 | 273 |
test10_Contains8BitCharacters |
288 | 274 |
0 to:65 do:[:l | |
1421 | 275 |
|str| |
283 | 276 |
|
1421 | 277 |
str := String new:l. |
278 |
str atAllPut:(Character value:16r7F). |
|
279 |
self assert:( str contains8BitCharacters not ). |
|
283 | 280 |
|
1421 | 281 |
1 to:l do:[:pos | |
282 |
str at:pos put:(Character value:16r80). |
|
283 |
self assert:( str contains8BitCharacters ). |
|
284 |
str at:pos put:(Character value:16r7F). |
|
285 |
]. |
|
283 | 286 |
]. |
287 |
||
288 |
" |
|
284 | 289 |
self new test10_Contains8BitCharacters |
283 | 290 |
" |
288 | 291 |
! |
292 |
||
1426 | 293 |
test11_IsEmpty |
294 |
|nul n| |
|
295 |
nul := 0 asCharacter. |
|
296 |
n := 1. |
|
297 |
self assert:('' isEmpty). |
|
298 |
self assert:(' ' isEmpty not). |
|
299 |
self assert:(nul asCharacter asString isEmpty not). |
|
300 |
self assert:(('' , nul) isEmpty not). |
|
301 |
self assert:((String new:0) isEmpty). |
|
302 |
self assert:((String new:17 withAll:nul) isEmpty not). |
|
303 |
||
1447 | 304 |
29 timesRepeat:[ |
305 |
|s| |
|
1426 | 306 |
|
1447 | 307 |
s := String new:(n + 17). |
308 |
self assert:(s isEmpty not). |
|
309 |
n := n * 2. |
|
1426 | 310 |
]. |
311 |
self assert:((String new:17 withAll:nul) isEmpty not). |
|
312 |
self assert:((String new:0 withAll:nul) isEmpty). |
|
313 |
" |
|
1429 | 314 |
self new test11_IsEmpty |
315 |
" |
|
1426 | 316 |
! |
317 |
||
318 |
test12_Comparison |
|
319 |
0 to: 255 do: [ :i | |
|
1447 | 320 |
|s t| |
1426 | 321 |
|
1447 | 322 |
1 to: 9 do: [ :j | |
323 |
s := String new:j withAll:(i asCharacter). |
|
324 |
t := s copy. |
|
1426 | 325 |
|
1447 | 326 |
self assert:(s notNil). |
327 |
self assert:(s = s). |
|
328 |
self assert:(s ~= s) not. |
|
329 |
self assert:(s < s) not. |
|
330 |
self assert:(s > s) not. |
|
331 |
self assert:(s = (s,s)) not. |
|
1426 | 332 |
|
1447 | 333 |
self assert:(t notNil). |
334 |
self assert:(s = t). |
|
335 |
self assert:(s ~= t) not. |
|
336 |
self assert:(s < t) not. |
|
337 |
self assert:(s > t) not. |
|
1426 | 338 |
|
1447 | 339 |
self assert:((s = nil) == ((s ~= nil) not)). |
340 |
self assert:((s = '') == ((s ~= '') not)). |
|
341 |
]. |
|
1426 | 342 |
|
1447 | 343 |
s := i asCharacter asString. |
344 |
0 to: 255 do: [ :j | |
|
345 |
t := j asCharacter asString. |
|
346 |
self assert:(t notNil). |
|
1426 | 347 |
|
1447 | 348 |
self assert:((s = t) == ((s ~= t) not)). |
349 |
] |
|
1426 | 350 |
]. |
351 |
||
352 |
" |
|
353 |
self new test12_Comparison |
|
354 |
" |
|
355 |
! |
|
356 |
||
357 |
test15_CompareWithCollating |
|
358 |
| nul | |
|
359 |
||
360 |
nul := 0 asCharacter asString. |
|
361 |
self assert:('' compareWith:'' collating:true) == 0. |
|
362 |
self assert:('' compareWith:'' collating:false) == 0. |
|
1447 | 363 |
self assert:(nul compareWith:(255 asCharacter asString) collating:false) == -1. |
1426 | 364 |
self assert:((255 asCharacter asString) compareWith:nul collating:false) == 1. |
1433 | 365 |
"/ This will fail and is a WONTFIX |
366 |
"/ self assert:((('' compareWith:nul collating:false) == 0) == ('' = nul)). |
|
1426 | 367 |
|
368 |
0 to: 255 do: [ :i | |
|
1447 | 369 |
|s| |
1426 | 370 |
|
1447 | 371 |
s := i asCharacter asString. |
372 |
self assert:(s notNil). |
|
1426 | 373 |
|
1447 | 374 |
"/ This will fail and is a WONTFIX |
375 |
"/ self assert:('' compareWith:s collating:false) ~= 0. |
|
376 |
self assert:('' compareWith:s collating:false) == ((s compareWith:'' collating:false) negated). |
|
1426 | 377 |
|
1447 | 378 |
0 to: 255 do: [ :j | |
379 |
| t | |
|
380 |
t := j asCharacter asString. |
|
381 |
self assert:(t notNil). |
|
1426 | 382 |
|
1447 | 383 |
self assert:(((s compareWith:t collating:false) == -1) == (s < t)). |
384 |
self assert:(((s compareWith:t collating:false) == 0) == (s = t)). |
|
385 |
self assert:(((s compareWith:t collating:false) == 1) == (s > t)). |
|
386 |
self assert:(((s compareWith:t collating:true) == -1) == (s < t)). |
|
387 |
self assert:(((s compareWith:t collating:true) == 0) == (s = t)). |
|
388 |
self assert:(((s compareWith:t collating:true) == 1) == (s > t)). |
|
389 |
] |
|
1426 | 390 |
]. |
391 |
||
392 |
0 to: 9 do: [ :i | |
|
1447 | 393 |
0 to: 255 do: [ :j | |
394 |
|s t| |
|
395 |
s := String new:i withAll:(j asCharacter). |
|
396 |
t := s copy. |
|
1426 | 397 |
|
1447 | 398 |
self assert: (s compareWith:s collating:false) == 0. |
399 |
self assert: (s compareWith:s collating:true) == 0. |
|
400 |
self assert: (s compareWith:t collating:false) == 0. |
|
401 |
self assert: (s compareWith:t collating:true) == 0 |
|
402 |
] |
|
1426 | 403 |
]. |
404 |
||
405 |
" |
|
406 |
self new test15_CompareWithCollating |
|
407 |
" |
|
408 |
! |
|
409 |
||
288 | 410 |
test20_literalsAreReadonly |
605
6f0411c4d46f
changed: #test20_literalsAreReadonly
Claus Gittinger <cg@exept.de>
parents:
571
diff
changeset
|
411 |
|myClass s1 l2 s2 parserFlags compiler| |
6f0411c4d46f
changed: #test20_literalsAreReadonly
Claus Gittinger <cg@exept.de>
parents:
571
diff
changeset
|
412 |
|
6f0411c4d46f
changed: #test20_literalsAreReadonly
Claus Gittinger <cg@exept.de>
parents:
571
diff
changeset
|
413 |
parserFlags := Compiler new parserFlags copy. |
6f0411c4d46f
changed: #test20_literalsAreReadonly
Claus Gittinger <cg@exept.de>
parents:
571
diff
changeset
|
414 |
parserFlags stringsAreImmutable:true. |
6f0411c4d46f
changed: #test20_literalsAreReadonly
Claus Gittinger <cg@exept.de>
parents:
571
diff
changeset
|
415 |
parserFlags arraysAreImmutable:true. |
288 | 416 |
|
417 |
Class withoutUpdatingChangesDo:[ |
|
1421 | 418 |
myClass := Object |
419 |
subclass:#'MyClass' |
|
420 |
instanceVariableNames:'' |
|
421 |
classVariableNames:'' |
|
422 |
poolDictionaries:nil. |
|
605
6f0411c4d46f
changed: #test20_literalsAreReadonly
Claus Gittinger <cg@exept.de>
parents:
571
diff
changeset
|
423 |
|
1421 | 424 |
compiler := myClass compilerClass new. |
425 |
compiler parserFlags:parserFlags. |
|
426 |
compiler compile:'lit1 ^''hello''' forClass:myClass install:true. |
|
605
6f0411c4d46f
changed: #test20_literalsAreReadonly
Claus Gittinger <cg@exept.de>
parents:
571
diff
changeset
|
427 |
|
1421 | 428 |
compiler := myClass compilerClass new. |
429 |
compiler parserFlags:parserFlags. |
|
430 |
compiler compile:'lit2 ^#(''foo'' ''bar'' ''baz'')' forClass:myClass install:true. |
|
288 | 431 |
]. |
432 |
||
433 |
s1 := myClass new perform:#lit1. |
|
434 |
self assert:(s1 isString). |
|
435 |
self assert:(s1 class == ImmutableString). |
|
436 |
self should:[ s1 at:1 put:$H ] raise:Error. |
|
437 |
||
438 |
l2 := myClass new perform:#lit2. |
|
439 |
self assert:(l2 isArray). |
|
440 |
self assert:(l2 class == ImmutableArray). |
|
441 |
self should:[ l2 at:1 put:$H ] raise:Error. |
|
442 |
s2 := l2 at:1. |
|
443 |
self assert:(s2 isString). |
|
444 |
self assert:(s2 class == ImmutableString). |
|
445 |
self should:[ s2 at:1 put:$H ] raise:Error. |
|
446 |
||
447 |
" |
|
448 |
self new test20_literalsAreReadonly |
|
449 |
" |
|
605
6f0411c4d46f
changed: #test20_literalsAreReadonly
Claus Gittinger <cg@exept.de>
parents:
571
diff
changeset
|
450 |
|
6f0411c4d46f
changed: #test20_literalsAreReadonly
Claus Gittinger <cg@exept.de>
parents:
571
diff
changeset
|
451 |
"Modified: / 02-08-2011 / 19:30:53 / cg" |
352 | 452 |
! |
453 |
||
1418 | 454 |
test30_indexOfSubCollection |
352 | 455 |
|i| |
456 |
"/ 12345678901 |
|
457 |
i := 'hello world' indexOfSubCollection:'world' startingAt:1 ifAbsent:0 caseSensitive:true. |
|
458 |
self assert:(i == 7). |
|
459 |
i := 'hello wOrLd' indexOfSubCollection:'world' startingAt:1 ifAbsent:0 caseSensitive:true. |
|
460 |
self assert:(i == 0). |
|
461 |
i := 'hello wOrLd' indexOfSubCollection:'world' startingAt:1 ifAbsent:0 caseSensitive:false. |
|
462 |
self assert:(i == 7). |
|
463 |
i := 'hello wOrLd' indexOfSubCollection:'ll' startingAt:1 ifAbsent:0 caseSensitive:false. |
|
464 |
self assert:(i == 3). |
|
465 |
||
466 |
i := 'hello wOrLd yellow' indexOfSubCollection:'ll' startingAt:1 ifAbsent:0 caseSensitive:false. |
|
467 |
self assert:(i == 3). |
|
468 |
i := 'hello wOrLd yellow' indexOfSubCollection:'ll' startingAt:3 ifAbsent:0 caseSensitive:false. |
|
469 |
self assert:(i == 3). |
|
470 |
i := 'hello wOrLd yellow' indexOfSubCollection:'ll' startingAt:4 ifAbsent:0 caseSensitive:false. |
|
471 |
self assert:(i == 15). |
|
472 |
||
353 | 473 |
i := 'hello wOrLd yellow' indexOfSubCollection:'low' startingAt:1 ifAbsent:0 caseSensitive:false. |
474 |
self assert:(i == 16). |
|
475 |
i := 'hello wOrLd yellow' indexOfSubCollection:'low' startingAt:17 ifAbsent:0 caseSensitive:false. |
|
476 |
self assert:(i == 0). |
|
477 |
i := 'hello wOrLd yellow' indexOfSubCollection:'low' startingAt:18 ifAbsent:0 caseSensitive:false. |
|
478 |
self assert:(i == 0). |
|
479 |
||
352 | 480 |
" |
1418 | 481 |
self new test30_indexOfSubCollection |
352 | 482 |
" |
570 | 483 |
! |
484 |
||
485 |
test40_indexOfAny |
|
1426 | 486 |
|s i collection| |
570 | 487 |
|
488 |
s := 'Some Sample Generators (74035660-d1f6-11df-9ab3-00ff7b08316c)'. |
|
489 |
1 to:s size do:[:start | |
|
1447 | 490 |
i := s indexOfAny:'-' startingAt:start. |
491 |
self assert:(i == 0 or:[ i >= start]). |
|
492 |
(i ~~ 0) ifTrue:[ |
|
493 |
self assert:(s at:i) == $- |
|
494 |
]. |
|
1308 | 495 |
]. |
1447 | 496 |
"/ 123456789012 |
1308 | 497 |
s := 'bla bla 1234'. |
498 |
1 to:s size do:[:start | |
|
1447 | 499 |
i := s indexOfAny:'1234' startingAt:start. |
500 |
self assert:(i == 0 or:[ i >= start]). |
|
501 |
(i == 9) ifTrue:[ self assert:((s at:i) == $1) ]. |
|
502 |
(i == 10) ifTrue:[ self assert:((s at:i) == $2) ]. |
|
503 |
(i == 11) ifTrue:[ self assert:((s at:i) == $3) ]. |
|
504 |
(i == 12) ifTrue:[ self assert:((s at:i) == $4) ]. |
|
570 | 505 |
]. |
506 |
||
1426 | 507 |
collection := #($o, $l, $o). |
508 |
"/ 12345678901 |
|
509 |
i := 'hello world' indexOfAny:collection startingAt:1. |
|
510 |
self assert:(i == 3). |
|
511 |
i := 'hello world' indexOfAny:collection startingAt:2. |
|
512 |
self assert:(i == 3). |
|
513 |
i := 'hello world' indexOfAny:collection startingAt:3. |
|
1447 | 514 |
self assert:(i == 3). |
1426 | 515 |
i := 'hello world' indexOfAny:collection startingAt:4. |
1447 | 516 |
self assert:(i == 4). |
1426 | 517 |
i := 'hello world' indexOfAny:collection startingAt:5. |
1447 | 518 |
self assert:(i == 5). |
1426 | 519 |
i := 'hello world' indexOfAny:collection startingAt:6. |
1447 | 520 |
self assert:(i == 8). |
1426 | 521 |
i := 'hello world' indexOfAny:collection startingAt:7. |
522 |
self assert:(i == 8). |
|
523 |
i := 'hello world' indexOfAny:collection startingAt:8. |
|
1447 | 524 |
self assert:(i == 8). |
1426 | 525 |
i := 'hello world' indexOfAny:collection startingAt:9. |
1447 | 526 |
self assert:(i == 10). |
1426 | 527 |
i := 'hello world' indexOfAny:collection startingAt:10. |
1447 | 528 |
self assert:(i == 10). |
1426 | 529 |
i := 'hello world' indexOfAny:collection startingAt:11. |
530 |
self assert:(i == 0). |
|
531 |
i := 'hello world' indexOfAny:collection startingAt:12. |
|
532 |
self assert:(i == 0). |
|
533 |
i := 'hello world' indexOfAny:collection startingAt:10000. |
|
534 |
self assert:(i == 0). |
|
570 | 535 |
" |
536 |
self new test40_indexOfAny |
|
537 |
" |
|
538 |
||
539 |
"Created: / 29-10-2010 / 14:58:21 / cg" |
|
571 | 540 |
! |
541 |
||
1308 | 542 |
test41_contains |
543 |
|s| |
|
544 |
||
545 |
s := 'abcdefg'. |
|
546 |
self assert:(s contains:[:ch | ch == $a]). |
|
547 |
self assert:(s contains:[:ch | ch == $A]) not. |
|
548 |
self assert:(s contains:[:ch | ch == $1]) not. |
|
1426 | 549 |
self assert:(s contains:[:ch | ch == (0 asCharacter)]) not. |
1308 | 550 |
" |
551 |
self new test41_contains |
|
552 |
" |
|
553 |
! |
|
554 |
||
1420 | 555 |
test42_includesAny |
556 |
|s| |
|
557 |
||
558 |
1 to:20 do:[:na | |
|
1447 | 559 |
s := (String new:na withAll:$a),'bla bla 1234'. |
560 |
self assert:( s includesAny:'12'). |
|
561 |
self assert:( s includesAny:'21'). |
|
562 |
self assert:( s includesAny:'15'). |
|
563 |
self assert:( s includesAny:'51'). |
|
564 |
self assert:( s includesAny:'45'). |
|
565 |
self assert:( s includesAny:'54'). |
|
566 |
self assert:( s includesAny:'56') not. |
|
1420 | 567 |
]. |
1447 | 568 |
|
1420 | 569 |
" |
570 |
self new test42_includesAny |
|
571 |
" |
|
1421 | 572 |
! |
1420 | 573 |
|
1421 | 574 |
test43_occurrencesOf |
1418 | 575 |
|s| |
576 |
||
577 |
"/ 12345678901 |
|
578 |
self assert:( 'hello world' occurrencesOf:$0 ) == 0. |
|
1447 | 579 |
self assert:( 'hello world' occurrencesOf:$l ) == 3. |
580 |
self assert:( 'hello world' occurrencesOf:$d ) == 1. |
|
1418 | 581 |
|
582 |
"/ how about 0-bytes in between |
|
583 |
self assert:( #[0 0 1 0 0] asString occurrencesOf:(Character value:1) ) == 1. |
|
584 |
self assert:( #[0 0 1 0 0] asString occurrencesOf:(Character value:0) ) == 4. |
|
585 |
||
586 |
1 to:10 do:[:nA | |
|
1447 | 587 |
1 to:10 do:[:nB | |
588 |
s := (String new:nA withAll:$a),(String new:nB withAll:$b). |
|
589 |
self assert:(s occurrencesOf:$a) == nA. |
|
590 |
self assert:(s occurrencesOf:$b) == nB. |
|
591 |
] |
|
592 |
]. |
|
1418 | 593 |
|
594 |
s := String new:1024. |
|
595 |
s atAllPut:$a. |
|
596 |
s at:512 put:(Character space). |
|
597 |
self assert:(s occurrencesOf:(Character space)) == 1. |
|
598 |
self assert:(s occurrencesOf:$a) == 1023. |
|
599 |
||
600 |
s := String new:1024. |
|
601 |
s atAllPut:$a. |
|
602 |
1 to:1024 by:2 do:[:i | s at:i put:$b]. |
|
603 |
self assert:(s occurrencesOf:$a) == 512. |
|
604 |
self assert:(s occurrencesOf:$b) == 512. |
|
1421 | 605 |
|
1418 | 606 |
" |
1421 | 607 |
self new test43_occurrencesOf |
1418 | 608 |
" |
609 |
! |
|
610 |
||
571 | 611 |
test50_indexOf |
612 |
|s i| |
|
613 |
||
614 |
s := 'Some Sample Generators (74035660-d1f6-11df-9ab3-00ff7b08316c)'. |
|
615 |
1 to:s size do:[:start | |
|
1447 | 616 |
i := s indexOf:$- startingAt:start. |
617 |
self assert:(i == 0 or:[ i >= start]). |
|
571 | 618 |
]. |
1418 | 619 |
"/ 12345678901 |
620 |
self assert:( 'hello world' indexOf:$0 startingAt:1 ) == 0. |
|
1447 | 621 |
self assert:( 'hello world' indexOf:$l startingAt:1 ) == 3. |
622 |
self assert:( 'hello world' indexOf:$l startingAt:5 ) == 10. |
|
623 |
self assert:( 'hello world' indexOf:$d startingAt:5 ) == 11. |
|
1418 | 624 |
|
1426 | 625 |
"/ 12345678901 |
626 |
self assert:(('hello world' indexOf:$o startingAt:1) == 5). |
|
627 |
self assert:(('hello world' indexOf:$o startingAt:2) == 5). |
|
628 |
self assert:(('hello world' indexOf:$o startingAt:3) == 5). |
|
629 |
self assert:(('hello world' indexOf:$o startingAt:4) == 5). |
|
630 |
self assert:(('hello world' indexOf:$o startingAt:5) == 5). |
|
631 |
self assert:(('hello world' indexOf:$o startingAt:6) == 8). |
|
632 |
self assert:(('hello world' indexOf:$o startingAt:7) == 8). |
|
633 |
self assert:(('hello world' indexOf:$o startingAt:8) == 8). |
|
634 |
self assert:(('hello world' indexOf:$o startingAt:9) == 0). |
|
635 |
self assert:(('hello world' indexOf:$o startingAt:10) == 0). |
|
636 |
self assert:(('hello world' indexOf:$o startingAt:11) == 0). |
|
637 |
self assert:(('hello world' indexOf:$o startingAt:12) == 0). |
|
638 |
self assert:(('hello world' indexOf:$o startingAt:10000) == 0). |
|
639 |
||
1418 | 640 |
"/ how about 0-bytes in between |
641 |
self assert:( #[0 0 1 0 0] asString indexOf:(Character value:1) startingAt:1 ) == 3. |
|
642 |
self assert:( #[0 0 1 0 0] asString indexOf:(Character value:0) startingAt:3 ) == 4. |
|
643 |
self assert:( #[0 0 1 1 0] asString indexOf:(Character value:0) startingAt:3 ) == 5. |
|
644 |
self assert:( #[0 1 0 1 0] asString indexOf:(Character value:1) startingAt:3 ) == 4. |
|
645 |
||
646 |
s := '12345678901234b'. |
|
647 |
self assert:(s indexOf:$x) == 0. |
|
648 |
self assert:(s indexOf:$1) == 1. |
|
649 |
self assert:(s indexOf:$2) == 2. |
|
650 |
self assert:(s indexOf:$3) == 3. |
|
651 |
self assert:(s indexOf:$4) == 4. |
|
652 |
self assert:(s indexOf:$5) == 5. |
|
653 |
self assert:(s indexOf:$0) == 10. |
|
654 |
self assert:(s indexOf:$b) == 15. |
|
655 |
||
656 |
s := ''. |
|
657 |
self assert:(s indexOf:$1) == 0. |
|
658 |
s := '1'. |
|
659 |
self assert:(s indexOf:$1) == 1. |
|
660 |
self assert:(s indexOf:$2) == 0. |
|
661 |
s := '12'. |
|
662 |
self assert:(s indexOf:$1) == 1. |
|
663 |
self assert:(s indexOf:$2) == 2. |
|
664 |
self assert:(s indexOf:$3) == 0. |
|
665 |
s := '123'. |
|
666 |
self assert:(s indexOf:$1) == 1. |
|
667 |
self assert:(s indexOf:$2) == 2. |
|
668 |
self assert:(s indexOf:$3) == 3. |
|
669 |
self assert:(s indexOf:$4) == 0. |
|
670 |
s := '1234'. |
|
671 |
self assert:(s indexOf:$1) == 1. |
|
672 |
self assert:(s indexOf:$2) == 2. |
|
673 |
self assert:(s indexOf:$3) == 3. |
|
674 |
self assert:(s indexOf:$4) == 4. |
|
675 |
self assert:(s indexOf:$5) == 0. |
|
676 |
s := '12345'. |
|
677 |
self assert:(s indexOf:$1) == 1. |
|
678 |
self assert:(s indexOf:$2) == 2. |
|
679 |
self assert:(s indexOf:$3) == 3. |
|
680 |
self assert:(s indexOf:$4) == 4. |
|
681 |
self assert:(s indexOf:$5) == 5. |
|
682 |
self assert:(s indexOf:$6) == 0. |
|
683 |
s := '123456'. |
|
684 |
self assert:(s indexOf:$1) == 1. |
|
685 |
self assert:(s indexOf:$2) == 2. |
|
686 |
self assert:(s indexOf:$3) == 3. |
|
687 |
self assert:(s indexOf:$4) == 4. |
|
688 |
self assert:(s indexOf:$5) == 5. |
|
689 |
self assert:(s indexOf:$6) == 6. |
|
690 |
self assert:(s indexOf:$7) == 0. |
|
691 |
s := '1234567'. |
|
692 |
self assert:(s indexOf:$1) == 1. |
|
693 |
self assert:(s indexOf:$2) == 2. |
|
694 |
self assert:(s indexOf:$3) == 3. |
|
695 |
self assert:(s indexOf:$4) == 4. |
|
696 |
self assert:(s indexOf:$5) == 5. |
|
697 |
self assert:(s indexOf:$6) == 6. |
|
698 |
self assert:(s indexOf:$7) == 7. |
|
699 |
self assert:(s indexOf:$8) == 0. |
|
700 |
s := '12345678'. |
|
701 |
self assert:(s indexOf:$1) == 1. |
|
702 |
self assert:(s indexOf:$2) == 2. |
|
703 |
self assert:(s indexOf:$3) == 3. |
|
704 |
self assert:(s indexOf:$4) == 4. |
|
705 |
self assert:(s indexOf:$5) == 5. |
|
706 |
self assert:(s indexOf:$6) == 6. |
|
707 |
self assert:(s indexOf:$7) == 7. |
|
708 |
self assert:(s indexOf:$8) == 8. |
|
709 |
self assert:(s indexOf:$9) == 0. |
|
710 |
s := '123456789'. |
|
711 |
self assert:(s indexOf:$1) == 1. |
|
712 |
self assert:(s indexOf:$2) == 2. |
|
713 |
self assert:(s indexOf:$3) == 3. |
|
714 |
self assert:(s indexOf:$4) == 4. |
|
715 |
self assert:(s indexOf:$5) == 5. |
|
716 |
self assert:(s indexOf:$6) == 6. |
|
717 |
self assert:(s indexOf:$7) == 7. |
|
718 |
self assert:(s indexOf:$8) == 8. |
|
719 |
self assert:(s indexOf:$9) == 9. |
|
720 |
||
721 |
self assert:(s indexOf:$0) == 0. |
|
722 |
self assert:(s indexOf:$b) == 0. |
|
723 |
||
724 |
s := String new:1024. |
|
725 |
s atAllPut:$a. |
|
726 |
s at:512 put:(Character space). |
|
727 |
self assert:(s indexOf:(Character space)) == 512. |
|
728 |
self assert:(s indexOf:(Character space) startingAt:1) == 512. |
|
729 |
self assert:(s indexOf:(Character space) startingAt:2) == 512. |
|
730 |
self assert:(s indexOf:(Character space) startingAt:3) == 512. |
|
731 |
self assert:(s indexOf:(Character space) startingAt:4) == 512. |
|
732 |
self assert:(s indexOf:(Character space) startingAt:5) == 512. |
|
733 |
self assert:(s indexOf:(Character space) startingAt:6) == 512. |
|
734 |
self assert:(s indexOf:(Character space) startingAt:7) == 512. |
|
735 |
self assert:(s indexOf:(Character space) startingAt:8) == 512. |
|
736 |
self assert:(s indexOf:(Character space) startingAt:9) == 512. |
|
737 |
self assert:(s indexOf:(Character space) startingAt:511) == 512. |
|
738 |
self assert:(s indexOf:(Character space) startingAt:512) == 512. |
|
739 |
self assert:(s indexOf:(Character space) startingAt:513) == 0. |
|
571 | 740 |
|
741 |
" |
|
742 |
self new test50_indexOf |
|
743 |
" |
|
744 |
||
745 |
"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
|
746 |
! |
8c9ff6c5efe2
Added string hashing tests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
702
diff
changeset
|
747 |
|
1373 | 748 |
test51_substrings |
749 |
self assert:('aaa/bbb/ccc' subStrings:'/') asArray = #('aaa' 'bbb' 'ccc'). |
|
750 |
self assert:(('aaa/bbb/ccc' subStrings:'/') asStringWith:'/') = 'aaa/bbb/ccc'. |
|
751 |
||
1385 | 752 |
"/ self assert:('/aaa/bbb/ccc' subStrings:'/') asArray = #('' 'aaa' 'bbb' 'ccc'). |
753 |
"/ self assert:(('/aaa/bbb/ccc' subStrings:'/') asStringWith:'/') = '/aaa/bbb/ccc'. |
|
754 |
"/ |
|
755 |
"/ self assert:('aaa/bbb/ccc/' subStrings:'/') asArray = #('aaa' 'bbb' 'ccc' '' ). |
|
756 |
"/ self assert:(('aaa/bbb/ccc/' subStrings:'/') asStringWith:'/') = '/aaa/bbb/ccc/'. |
|
757 |
"/ |
|
758 |
"/ self assert:('/aaa/bbb/ccc/' subStrings:'/') asArray = #('' 'aaa' 'bbb' 'ccc' ''). |
|
759 |
"/ self assert:(('/aaa/bbb/ccc/' subStrings:'/') asStringWith:'/') = '/aaa/bbb/ccc'' '. |
|
760 |
"/ |
|
761 |
"/ self assert:('//aaa/bbb/ccc' subStrings:'/') asArray = #('' '' 'aaa' 'bbb' 'ccc'). |
|
762 |
"/ self assert:(('//aaa/bbb/ccc' subStrings:'/') asStringWith:'/') = '//aaa/bbb/ccc'. |
|
1373 | 763 |
|
764 |
" |
|
765 |
self new test51_substrings |
|
766 |
" |
|
767 |
! |
|
768 |
||
1420 | 769 |
test52_indexOfSeparator |
1426 | 770 |
|j s| |
1420 | 771 |
|
772 |
self assert:('' indexOfSeparator) == 0. |
|
773 |
1 to:20 do:[:n | |
|
1447 | 774 |
s := (String new:n withAll:$a). |
775 |
1 to:20 do:[:start | |
|
776 |
self assert:(s indexOfSeparatorStartingAt:start) == 0. |
|
777 |
]. |
|
778 |
]. |
|
1420 | 779 |
1 to:20 do:[:n | |
1447 | 780 |
s := (String new:n withAll:$a),' '. |
781 |
1 to:n do:[:start | |
|
782 |
self assert:(s indexOfSeparatorStartingAt:start) == (n+1). |
|
783 |
]. |
|
784 |
]. |
|
785 |
||
786 |
{ |
|
787 |
Character space . |
|
788 |
Character tab . |
|
789 |
Character return . |
|
790 |
Character lf . |
|
1420 | 791 |
} do:[:sep | |
1447 | 792 |
1 to:20 do:[:na | |
793 |
1 to:20 do:[:nb | |
|
794 |
s := (String new:na withAll:$a),sep,(String new:na withAll:$a). |
|
795 |
1 to:na do:[:start | |
|
796 |
self assert:(s indexOfSeparatorStartingAt:start) == (na+1). |
|
797 |
] |
|
798 |
] |
|
799 |
]. |
|
1420 | 800 |
]. |
1447 | 801 |
|
802 |
{ |
|
803 |
Character esc . |
|
804 |
Character null . |
|
805 |
$a . |
|
1420 | 806 |
} do:[:nonSep | |
1447 | 807 |
1 to:20 do:[:na | |
808 |
1 to:20 do:[:nb | |
|
809 |
s := (String new:na withAll:$a),nonSep,(String new:na withAll:$a). |
|
810 |
1 to:20 do:[:start | |
|
811 |
self assert:(s indexOfSeparatorStartingAt:start) == 0. |
|
812 |
] |
|
813 |
] |
|
814 |
]. |
|
1420 | 815 |
]. |
816 |
||
1426 | 817 |
s := String new:1000 withAll:$a. |
818 |
self assert:(s indexOfSeparatorStartingAt:1) == 0. |
|
819 |
400 to: 417 do:[:i | |
|
1447 | 820 |
s := String new:1000 withAll:$a. |
821 |
s at:i put:(Character space). |
|
822 |
self assert:(s indexOfSeparatorStartingAt:1) == i. |
|
1426 | 823 |
|
1447 | 824 |
s := String new:1000 withAll:$a. |
825 |
s at:i put:(Character return). |
|
826 |
self assert:(s indexOfSeparatorStartingAt:1) == i. |
|
827 |
]. |
|
1426 | 828 |
|
829 |
"/ 12345678901 |
|
830 |
j := 'hello world' indexOfSeparatorStartingAt:1. |
|
831 |
self assert:(j == 6). |
|
832 |
j := 'hello world ' indexOfSeparatorStartingAt:2. |
|
833 |
self assert:(j == 6). |
|
834 |
j := 'hello world ' indexOfSeparatorStartingAt:3. |
|
1447 | 835 |
self assert:(j == 6). |
1426 | 836 |
j := 'hello world ' indexOfSeparatorStartingAt:4. |
1447 | 837 |
self assert:(j == 6). |
1426 | 838 |
j := 'hello world ' indexOfSeparatorStartingAt:5. |
839 |
self assert:(j == 6). |
|
840 |
j := 'hello world ' indexOfSeparatorStartingAt:6. |
|
841 |
self assert:(j == 6). |
|
842 |
j := 'hello world ' indexOfSeparatorStartingAt:7. |
|
843 |
self assert:(j == 12). |
|
844 |
j := 'hello world ' indexOfSeparatorStartingAt:8. |
|
845 |
self assert:(j == 12). |
|
846 |
j := 'hello world ' indexOfSeparatorStartingAt:9. |
|
1447 | 847 |
self assert:(j == 12). |
1426 | 848 |
j := 'hello world ' indexOfSeparatorStartingAt:10. |
1447 | 849 |
self assert:(j == 12). |
1426 | 850 |
j := 'hello world ' indexOfSeparatorStartingAt:11. |
851 |
self assert:(j == 12). |
|
852 |
j := 'hello world ' indexOfSeparatorStartingAt:12. |
|
853 |
self assert:(j == 12). |
|
854 |
j := 'hello world' indexOfSeparatorStartingAt:12. |
|
1447 | 855 |
self assert:(j == 0). |
1426 | 856 |
j := 'hello world ' indexOfSeparatorStartingAt:13. |
857 |
self assert:(j == 0). |
|
858 |
j := 'hello world ' indexOfSeparatorStartingAt:10000. |
|
1447 | 859 |
self assert:(j == 0). |
860 |
||
1420 | 861 |
" |
862 |
self new test52_indexOfSeparator |
|
863 |
" |
|
864 |
! |
|
865 |
||
866 |
test54_occurrencesOf |
|
867 |
|s| |
|
868 |
||
869 |
self assert:('' occurrencesOf:$a) == 0. |
|
870 |
1 to:20 do:[:n | |
|
1447 | 871 |
s := (String new:n withAll:$a). |
872 |
self assert:(s occurrencesOf:$a) == n. |
|
873 |
]. |
|
1420 | 874 |
1 to:20 do:[:na | |
1447 | 875 |
1 to:20 do:[:nb | |
876 |
s := (String new:na withAll:$a),(String new:nb withAll:$b). |
|
877 |
self assert:(s occurrencesOf:$a) == na. |
|
878 |
]. |
|
879 |
]. |
|
1420 | 880 |
1 to:40 do:[:n | |
1447 | 881 |
s := String new:n withAll:$a. |
882 |
1 to:n by:2 do:[:n | |
|
883 |
s at:n put:$b. |
|
884 |
]. |
|
885 |
self assert:(s occurrencesOf:$a) == (n // 2). |
|
886 |
]. |
|
887 |
||
1420 | 888 |
s := String new:1000 withAll:$a. |
889 |
self assert:(s occurrencesOf:$a) == 1000. |
|
890 |
1 to:1000 do:[:i | |
|
1447 | 891 |
s at:i put:$b. |
892 |
self assert:(s occurrencesOf:$a) == (1000-i). |
|
893 |
self assert:(s occurrencesOf:$b) == i. |
|
1420 | 894 |
]. |
1447 | 895 |
|
1420 | 896 |
" |
897 |
self new test54_occurrencesOf |
|
898 |
" |
|
899 |
! |
|
900 |
||
751
8c9ff6c5efe2
Added string hashing tests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
702
diff
changeset
|
901 |
test60_hash |
8c9ff6c5efe2
Added string hashing tests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
702
diff
changeset
|
902 |
" |
8c9ff6c5efe2
Added string hashing tests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
702
diff
changeset
|
903 |
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
|
904 |
returned different values. This test checks this |
8c9ff6c5efe2
Added string hashing tests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
702
diff
changeset
|
905 |
" |
8c9ff6c5efe2
Added string hashing tests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
702
diff
changeset
|
906 |
|
753
81af28f807cf
class: RegressionTests::StringTests
Stefan Vogel <sv@exept.de>
parents:
752
diff
changeset
|
907 |
| tester | |
751
8c9ff6c5efe2
Added string hashing tests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
702
diff
changeset
|
908 |
|
753
81af28f807cf
class: RegressionTests::StringTests
Stefan Vogel <sv@exept.de>
parents:
752
diff
changeset
|
909 |
tester := [:s| |
1447 | 910 |
|sHash u16Hash u32Hash| |
1385 | 911 |
|
1447 | 912 |
sHash := s hash. |
913 |
u16Hash := s asUnicode16String hash. |
|
914 |
u32Hash := s asUnicode32String hash. |
|
1385 | 915 |
|
1447 | 916 |
self assert: sHash == u16Hash |
917 |
description: ('String and Unicode16String hashes differ on "%1" (%2)' |
|
918 |
bindWith:s with:s class name). |
|
919 |
self assert: sHash == u32Hash |
|
920 |
description: ('String and Unicode32String hashes differ on "%1" (%2)' |
|
921 |
bindWith:s with:s class name) |
|
751
8c9ff6c5efe2
Added string hashing tests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
702
diff
changeset
|
922 |
]. |
8c9ff6c5efe2
Added string hashing tests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
702
diff
changeset
|
923 |
|
753
81af28f807cf
class: RegressionTests::StringTests
Stefan Vogel <sv@exept.de>
parents:
752
diff
changeset
|
924 |
tester value:'a'. |
1385 | 925 |
tester value:'12345678901234'. |
926 |
tester value:'1234567890123'. |
|
927 |
tester value:'123456789012'. |
|
928 |
tester value:'12345678901'. |
|
929 |
tester value:'1234567890'. |
|
930 |
tester value:'123456789'. |
|
753
81af28f807cf
class: RegressionTests::StringTests
Stefan Vogel <sv@exept.de>
parents:
752
diff
changeset
|
931 |
tester value:'12345678'. |
81af28f807cf
class: RegressionTests::StringTests
Stefan Vogel <sv@exept.de>
parents:
752
diff
changeset
|
932 |
tester value:'1234567'. |
81af28f807cf
class: RegressionTests::StringTests
Stefan Vogel <sv@exept.de>
parents:
752
diff
changeset
|
933 |
tester value:'123456'. |
1385 | 934 |
tester value:'12345'. |
935 |
tester value:'1234'. |
|
936 |
tester value:'123'. |
|
937 |
tester value:'12'. |
|
753
81af28f807cf
class: RegressionTests::StringTests
Stefan Vogel <sv@exept.de>
parents:
752
diff
changeset
|
938 |
tester value:'boolean'. |
751
8c9ff6c5efe2
Added string hashing tests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
702
diff
changeset
|
939 |
|
1417 | 940 |
"/ strings with 0-elements |
941 |
tester value:('' copyWith:Character null). |
|
942 |
tester value:('1' copyWith:Character null). |
|
943 |
tester value:('12' copyWith:Character null). |
|
944 |
tester value:('123' copyWith:Character null). |
|
945 |
tester value:('1234' copyWith:Character null). |
|
946 |
tester value:('12345' copyWith:Character null). |
|
947 |
tester value:('123456' copyWith:Character null). |
|
948 |
tester value:('1234567' copyWith:Character null). |
|
949 |
tester value:('12345678' copyWith:Character null). |
|
950 |
tester value:('123456789' copyWith:Character null). |
|
1419 | 951 |
|
952 |
tester value:('' copyWith:Character null),'123'. |
|
953 |
tester value:('1' copyWith:Character null),'123'. |
|
954 |
tester value:('12' copyWith:Character null),'123'. |
|
955 |
tester value:('123' copyWith:Character null),'123'. |
|
956 |
tester value:('1234' copyWith:Character null),'123'. |
|
957 |
tester value:('12345' copyWith:Character null),'123'. |
|
958 |
tester value:('123456' copyWith:Character null),'123'. |
|
959 |
tester value:('1234567' copyWith:Character null),'123'. |
|
960 |
tester value:('12345678' copyWith:Character null),'123'. |
|
961 |
tester value:('123456789' copyWith:Character null),'123'. |
|
1447 | 962 |
|
1419 | 963 |
"/ String allInstancesDo:[:each| tester value:each]. |
753
81af28f807cf
class: RegressionTests::StringTests
Stefan Vogel <sv@exept.de>
parents:
752
diff
changeset
|
964 |
Symbol allInstancesDo:[:each| tester value:each]. |
751
8c9ff6c5efe2
Added string hashing tests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
702
diff
changeset
|
965 |
|
8c9ff6c5efe2
Added string hashing tests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
702
diff
changeset
|
966 |
"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
|
967 |
! |
2fca937dc59b
class: RegressionTests::StringTests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
874
diff
changeset
|
968 |
|
1426 | 969 |
test65_concatenation |
970 |
|strA strB| |
|
971 |
||
1447 | 972 |
0 to:32 do:[:szA | |
973 |
0 to:32 do:[:szB | |
|
974 |
|szAB| |
|
1426 | 975 |
|
1447 | 976 |
strA := String new:szA withAll:$a. |
977 |
strB := String new:szB withAll:$b. |
|
978 |
szAB := szA + szB. |
|
979 |
self assert:(szA = strA size). |
|
980 |
self assert:(szB = strB size). |
|
981 |
10000 timesRepeat:[ |
|
982 |
|strAB| |
|
1426 | 983 |
|
1447 | 984 |
strAB := strA , strB. |
1426 | 985 |
|
1447 | 986 |
self assert:(szAB == strAB size). |
987 |
] |
|
988 |
] |
|
1426 | 989 |
]. |
990 |
||
991 |
strA := strB := ''. |
|
992 |
self assert: ((strA , strB) = ''). |
|
993 |
self assert: ((strA , strA) = ''). |
|
994 |
strA := 'a'. |
|
1447 | 995 |
self assert: ((strA , strA) = 'aa'). |
1426 | 996 |
self assert: ((strA , strB) = 'a'). |
997 |
strA := ''. |
|
998 |
strB := 'b'. |
|
1447 | 999 |
self assert: ((strA , strB) = 'b'). |
1426 | 1000 |
strA := 'b'. |
1001 |
strB := 'a'. |
|
1447 | 1002 |
self assert: ((strB , strA) = 'ab'). |
1426 | 1003 |
" |
1004 |
self new test65_concatenation |
|
1005 |
" |
|
1006 |
! |
|
1007 |
||
1008 |
test66_replace |
|
1009 |
|strA| |
|
1010 |
||
1011 |
1 to:64 do:[:szA | |
|
1447 | 1012 |
strA := String new:szA withAll:$a. |
1013 |
1 to:szA do:[:idx | |
|
1014 |
strA at:idx put:$*. |
|
1426 | 1015 |
|
1447 | 1016 |
strA replaceAll:$* with:$#. |
1426 | 1017 |
|
1447 | 1018 |
self assert:(strA at:idx) = $#. |
1019 |
self assert:(strA occurrencesOf:$#) = idx. |
|
1020 |
self assert:(strA count:[:ch | ch = $#]) = idx. |
|
1021 |
self assert:(strA occurrencesOf:$*) = 0. |
|
1022 |
self assert:(strA count:[:ch | ch = $*]) = 0. |
|
1023 |
self assert:(strA includes:$#). |
|
1024 |
self assert:(strA includes:$*) not. |
|
1025 |
] |
|
1426 | 1026 |
] |
1027 |
||
1028 |
" |
|
1029 |
self new test66_replace |
|
1030 |
" |
|
1031 |
! |
|
1032 |
||
1033 |
test67_concatenationAnd |
|
1034 |
|strA strB strC| |
|
1035 |
||
1447 | 1036 |
0 to:32 do:[:szA | |
1037 |
0 to:32 do:[:szB | |
|
1038 |
0 to:32 do:[:szC | |
|
1039 |
|szABC| |
|
1040 |
strA := String new:szA withAll:$a. |
|
1041 |
strB := String new:szB withAll:$b. |
|
1042 |
strC := String new:szC withAll:$c. |
|
1426 | 1043 |
|
1447 | 1044 |
szABC := szA + szB + szC. |
1045 |
self assert:(szA = strA size). |
|
1046 |
self assert:(szB = strB size). |
|
1047 |
self assert:(szC = strC size). |
|
1426 | 1048 |
|
1447 | 1049 |
300 timesRepeat:[ |
1050 |
|strABC| |
|
1426 | 1051 |
|
1447 | 1052 |
strABC := strA concatenate:strB and:strC. |
1426 | 1053 |
|
1447 | 1054 |
self assert:(szABC == strABC size). |
1055 |
] |
|
1056 |
] |
|
1057 |
] |
|
1426 | 1058 |
]. |
1059 |
strA := strB := strC := ''. |
|
1060 |
self assert: ((strA concatenate:strB and:strC) = ''). |
|
1061 |
strA := 'a'. |
|
1062 |
self assert: ((strA concatenate:strB and:strC) = 'a'). |
|
1063 |
strA := ''. |
|
1064 |
strB := 'b'. |
|
1447 | 1065 |
self assert: ((strA concatenate:strB and:strC) = 'b'). |
1426 | 1066 |
strB := ''. |
1067 |
strC := 'c'. |
|
1447 | 1068 |
self assert: ((strA concatenate:strB and:strC) = 'c'). |
1426 | 1069 |
strA := 'c'. |
1070 |
strB := 'b'. |
|
1071 |
strC := 'a'. |
|
1447 | 1072 |
self assert: ((strC concatenate:strB and:strA) = 'abc'). |
1426 | 1073 |
" |
1074 |
self new test67_concatenationAnd |
|
1075 |
" |
|
1076 |
! |
|
1077 |
||
1078 |
test68_concatenationAndAnd |
|
1079 |
|strA strB strC strD| |
|
1080 |
||
1447 | 1081 |
0 to:32 do:[:szA | |
1082 |
strA := String new:szA withAll:$a. |
|
1083 |
self assert:(szA = strA size). |
|
1084 |
0 to:32 do:[:szB | |
|
1085 |
strB := String new:szB withAll:$b. |
|
1086 |
self assert:(szB = strB size). |
|
1087 |
0 to:32 do:[:szC | |
|
1088 |
strC := String new:szC withAll:$c. |
|
1089 |
self assert:(szC = strC size). |
|
1090 |
0 to:32 do:[:szD | |
|
1091 |
|szABCD| |
|
1092 |
strD := String new:szD withAll:$d. |
|
1426 | 1093 |
|
1447 | 1094 |
szABCD := szA + szB + szC + szD. |
1426 | 1095 |
|
1447 | 1096 |
self assert:(szD = strD size). |
1426 | 1097 |
|
1447 | 1098 |
5 timesRepeat:[ |
1099 |
|strABCD| |
|
1426 | 1100 |
|
1447 | 1101 |
strABCD := strA concatenate:strB and:strC and:strD. |
1426 | 1102 |
|
1447 | 1103 |
self assert:(szABCD == strABCD size). |
1104 |
] |
|
1105 |
] |
|
1106 |
] |
|
1107 |
] |
|
1426 | 1108 |
]. |
1109 |
||
1110 |
strA := strB := strC := strD := ''. |
|
1111 |
self assert: ((strA concatenate:strB and:strC and:strD) = ''). |
|
1112 |
strA := 'a'. |
|
1113 |
self assert: ((strA concatenate:strB and:strC and:strD) = 'a'). |
|
1114 |
strA := ''. |
|
1115 |
strB := 'b'. |
|
1447 | 1116 |
self assert: ((strA concatenate:strB and:strC and:strD) = 'b'). |
1426 | 1117 |
strB := ''. |
1118 |
strC := 'c'. |
|
1447 | 1119 |
self assert: ((strA concatenate:strB and:strC and:strD) = 'c'). |
1426 | 1120 |
strC := ''. |
1121 |
strD := 'd'. |
|
1447 | 1122 |
self assert: ((strA concatenate:strB and:strC and:strD) = 'd'). |
1426 | 1123 |
strA := 'd'. |
1124 |
strB := 'c'. |
|
1125 |
strC := 'b'. |
|
1447 | 1126 |
strD := 'a'. |
1127 |
self assert: ((strD concatenate:strC and:strB and:strA) = 'abcd'). |
|
1426 | 1128 |
" |
1129 |
self new test68_concatenationAndAnd |
|
1130 |
" |
|
1131 |
! |
|
1132 |
||
962
2fca937dc59b
class: RegressionTests::StringTests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
874
diff
changeset
|
1133 |
test70_storeString |
2fca937dc59b
class: RegressionTests::StringTests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
874
diff
changeset
|
1134 |
|
2fca937dc59b
class: RegressionTests::StringTests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
874
diff
changeset
|
1135 |
self assert: 'AAA' storeString = '''AAA'''. |
2fca937dc59b
class: RegressionTests::StringTests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
874
diff
changeset
|
1136 |
self assert: 'A''A''A' storeString = '''A''''A''''A'''. |
2fca937dc59b
class: RegressionTests::StringTests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
874
diff
changeset
|
1137 |
|
2fca937dc59b
class: RegressionTests::StringTests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
874
diff
changeset
|
1138 |
self assert: 'AAA' asImmutableString storeString = '''AAA'''. |
2fca937dc59b
class: RegressionTests::StringTests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
874
diff
changeset
|
1139 |
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
|
1140 |
|
2fca937dc59b
class: RegressionTests::StringTests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
874
diff
changeset
|
1141 |
"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
|
1142 |
! |
373c0f5e539d
class: RegressionTests::StringTests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1060
diff
changeset
|
1143 |
|
373c0f5e539d
class: RegressionTests::StringTests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1060
diff
changeset
|
1144 |
test80_copyReplaceAll |
373c0f5e539d
class: RegressionTests::StringTests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1060
diff
changeset
|
1145 |
|
373c0f5e539d
class: RegressionTests::StringTests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1060
diff
changeset
|
1146 |
| orig copy | |
373c0f5e539d
class: RegressionTests::StringTests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1060
diff
changeset
|
1147 |
|
373c0f5e539d
class: RegressionTests::StringTests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1060
diff
changeset
|
1148 |
orig := 'AAA' copy. "/ In case literals are immutable... |
373c0f5e539d
class: RegressionTests::StringTests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1060
diff
changeset
|
1149 |
self assert: orig = 'AAA'. |
373c0f5e539d
class: RegressionTests::StringTests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1060
diff
changeset
|
1150 |
|
373c0f5e539d
class: RegressionTests::StringTests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1060
diff
changeset
|
1151 |
copy := orig copyReplaceAll: $A with: $X. |
373c0f5e539d
class: RegressionTests::StringTests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1060
diff
changeset
|
1152 |
self assert: copy = 'XXX'. |
373c0f5e539d
class: RegressionTests::StringTests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1060
diff
changeset
|
1153 |
self assert: orig = 'AAA'. |
373c0f5e539d
class: RegressionTests::StringTests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1060
diff
changeset
|
1154 |
|
373c0f5e539d
class: RegressionTests::StringTests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1060
diff
changeset
|
1155 |
orig := 'AAA' asImmutableString. |
373c0f5e539d
class: RegressionTests::StringTests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1060
diff
changeset
|
1156 |
self assert: orig = 'AAA'. |
373c0f5e539d
class: RegressionTests::StringTests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1060
diff
changeset
|
1157 |
|
373c0f5e539d
class: RegressionTests::StringTests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1060
diff
changeset
|
1158 |
copy := orig copyReplaceAll: $A with: $X. |
373c0f5e539d
class: RegressionTests::StringTests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1060
diff
changeset
|
1159 |
self assert: copy = 'XXX'. |
373c0f5e539d
class: RegressionTests::StringTests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1060
diff
changeset
|
1160 |
self assert: orig = 'AAA'. |
373c0f5e539d
class: RegressionTests::StringTests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1060
diff
changeset
|
1161 |
|
373c0f5e539d
class: RegressionTests::StringTests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1060
diff
changeset
|
1162 |
"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
|
1163 |
! |
11cb005634cb
class: RegressionTests::StringTests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1103
diff
changeset
|
1164 |
|
1240
4b187f56458b
class: RegressionTests::StringTests
Claus Gittinger <cg@exept.de>
parents:
1214
diff
changeset
|
1165 |
test81_filling |
4b187f56458b
class: RegressionTests::StringTests
Claus Gittinger <cg@exept.de>
parents:
1214
diff
changeset
|
1166 |
|
4b187f56458b
class: RegressionTests::StringTests
Claus Gittinger <cg@exept.de>
parents:
1214
diff
changeset
|
1167 |
| str | |
4b187f56458b
class: RegressionTests::StringTests
Claus Gittinger <cg@exept.de>
parents:
1214
diff
changeset
|
1168 |
|
4b187f56458b
class: RegressionTests::StringTests
Claus Gittinger <cg@exept.de>
parents:
1214
diff
changeset
|
1169 |
str := 'AAA' copy. "/ In case literals are immutable... |
4b187f56458b
class: RegressionTests::StringTests
Claus Gittinger <cg@exept.de>
parents:
1214
diff
changeset
|
1170 |
|
4b187f56458b
class: RegressionTests::StringTests
Claus Gittinger <cg@exept.de>
parents:
1214
diff
changeset
|
1171 |
str atAllPut:$B. |
4b187f56458b
class: RegressionTests::StringTests
Claus Gittinger <cg@exept.de>
parents:
1214
diff
changeset
|
1172 |
self assert: str = 'BBB'. |
4b187f56458b
class: RegressionTests::StringTests
Claus Gittinger <cg@exept.de>
parents:
1214
diff
changeset
|
1173 |
|
4b187f56458b
class: RegressionTests::StringTests
Claus Gittinger <cg@exept.de>
parents:
1214
diff
changeset
|
1174 |
str from:1 to:0 put:$C. |
4b187f56458b
class: RegressionTests::StringTests
Claus Gittinger <cg@exept.de>
parents:
1214
diff
changeset
|
1175 |
self assert: str = 'BBB'. |
4b187f56458b
class: RegressionTests::StringTests
Claus Gittinger <cg@exept.de>
parents:
1214
diff
changeset
|
1176 |
|
4b187f56458b
class: RegressionTests::StringTests
Claus Gittinger <cg@exept.de>
parents:
1214
diff
changeset
|
1177 |
str from:1 to:1 put:$D. |
4b187f56458b
class: RegressionTests::StringTests
Claus Gittinger <cg@exept.de>
parents:
1214
diff
changeset
|
1178 |
self assert: str = 'DBB'. |
4b187f56458b
class: RegressionTests::StringTests
Claus Gittinger <cg@exept.de>
parents:
1214
diff
changeset
|
1179 |
|
4b187f56458b
class: RegressionTests::StringTests
Claus Gittinger <cg@exept.de>
parents:
1214
diff
changeset
|
1180 |
str from:1 to:2 put:$E. |
4b187f56458b
class: RegressionTests::StringTests
Claus Gittinger <cg@exept.de>
parents:
1214
diff
changeset
|
1181 |
self assert: str = 'EEB'. |
4b187f56458b
class: RegressionTests::StringTests
Claus Gittinger <cg@exept.de>
parents:
1214
diff
changeset
|
1182 |
|
4b187f56458b
class: RegressionTests::StringTests
Claus Gittinger <cg@exept.de>
parents:
1214
diff
changeset
|
1183 |
str from:1 to:3 put:$F. |
4b187f56458b
class: RegressionTests::StringTests
Claus Gittinger <cg@exept.de>
parents:
1214
diff
changeset
|
1184 |
self assert: str = 'FFF'. |
4b187f56458b
class: RegressionTests::StringTests
Claus Gittinger <cg@exept.de>
parents:
1214
diff
changeset
|
1185 |
|
4b187f56458b
class: RegressionTests::StringTests
Claus Gittinger <cg@exept.de>
parents:
1214
diff
changeset
|
1186 |
str from:1 to:0 put:$G. |
4b187f56458b
class: RegressionTests::StringTests
Claus Gittinger <cg@exept.de>
parents:
1214
diff
changeset
|
1187 |
self assert: str = 'FFF'. |
4b187f56458b
class: RegressionTests::StringTests
Claus Gittinger <cg@exept.de>
parents:
1214
diff
changeset
|
1188 |
|
4b187f56458b
class: RegressionTests::StringTests
Claus Gittinger <cg@exept.de>
parents:
1214
diff
changeset
|
1189 |
str from:-1 to:-2 put:$G. |
4b187f56458b
class: RegressionTests::StringTests
Claus Gittinger <cg@exept.de>
parents:
1214
diff
changeset
|
1190 |
self assert: str = 'FFF'. |
4b187f56458b
class: RegressionTests::StringTests
Claus Gittinger <cg@exept.de>
parents:
1214
diff
changeset
|
1191 |
|
4b187f56458b
class: RegressionTests::StringTests
Claus Gittinger <cg@exept.de>
parents:
1214
diff
changeset
|
1192 |
self should:[ |
1421 | 1193 |
str from:-1 to:-1 put:$x |
1240
4b187f56458b
class: RegressionTests::StringTests
Claus Gittinger <cg@exept.de>
parents:
1214
diff
changeset
|
1194 |
] raise:SubscriptOutOfBoundsError. |
4b187f56458b
class: RegressionTests::StringTests
Claus Gittinger <cg@exept.de>
parents:
1214
diff
changeset
|
1195 |
self assert: str = 'FFF'. |
4b187f56458b
class: RegressionTests::StringTests
Claus Gittinger <cg@exept.de>
parents:
1214
diff
changeset
|
1196 |
|
4b187f56458b
class: RegressionTests::StringTests
Claus Gittinger <cg@exept.de>
parents:
1214
diff
changeset
|
1197 |
self should:[ |
1421 | 1198 |
str from:-1 to:1 put:$x |
1240
4b187f56458b
class: RegressionTests::StringTests
Claus Gittinger <cg@exept.de>
parents:
1214
diff
changeset
|
1199 |
] raise:SubscriptOutOfBoundsError. |
4b187f56458b
class: RegressionTests::StringTests
Claus Gittinger <cg@exept.de>
parents:
1214
diff
changeset
|
1200 |
self assert: str = 'FFF'. |
4b187f56458b
class: RegressionTests::StringTests
Claus Gittinger <cg@exept.de>
parents:
1214
diff
changeset
|
1201 |
! |
4b187f56458b
class: RegressionTests::StringTests
Claus Gittinger <cg@exept.de>
parents:
1214
diff
changeset
|
1202 |
|
1214
11cb005634cb
class: RegressionTests::StringTests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1103
diff
changeset
|
1203 |
test90_hash |
11cb005634cb
class: RegressionTests::StringTests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1103
diff
changeset
|
1204 |
| string8 string16 string32 | |
11cb005634cb
class: RegressionTests::StringTests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1103
diff
changeset
|
1205 |
|
11cb005634cb
class: RegressionTests::StringTests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1103
diff
changeset
|
1206 |
string8 := 'sun/nio/cs/UTF_8.class'. |
11cb005634cb
class: RegressionTests::StringTests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1103
diff
changeset
|
1207 |
string16 := string8 asUnicode16String. |
11cb005634cb
class: RegressionTests::StringTests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1103
diff
changeset
|
1208 |
string32 := string8 asUnicode16String. |
11cb005634cb
class: RegressionTests::StringTests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1103
diff
changeset
|
1209 |
|
11cb005634cb
class: RegressionTests::StringTests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1103
diff
changeset
|
1210 |
self assert: string8 hash == string16 hash. |
11cb005634cb
class: RegressionTests::StringTests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1103
diff
changeset
|
1211 |
self assert: string8 hash == string32 hash. |
11cb005634cb
class: RegressionTests::StringTests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1103
diff
changeset
|
1212 |
|
11cb005634cb
class: RegressionTests::StringTests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1103
diff
changeset
|
1213 |
"Created: / 09-10-2014 / 12:41:01 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
283 | 1214 |
! ! |
1215 |
||
1216 |
!StringTests class methodsFor:'documentation'! |
|
1217 |
||
1218 |
version |
|
1219 |
^ '$Header$' |
|
570 | 1220 |
! |
1221 |
||
1222 |
version_CVS |
|
1223 |
^ '$Header$' |
|
283 | 1224 |
! ! |
752
ef9236c7271c
class: RegressionTests::StringTests
Stefan Vogel <sv@exept.de>
parents:
751
diff
changeset
|
1225 |