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