1515
|
1 |
"{ Encoding: utf8 }"
|
|
2 |
|
1513
|
3 |
"{ Package: 'stx:goodies/regression' }"
|
|
4 |
|
|
5 |
"{ NameSpace: RegressionTests }"
|
|
6 |
|
|
7 |
TestCase subclass:#TypedArrayTests
|
|
8 |
instanceVariableNames:''
|
|
9 |
classVariableNames:''
|
|
10 |
poolDictionaries:''
|
|
11 |
category:'tests-Regression-Collections'
|
|
12 |
!
|
|
13 |
|
|
14 |
|
|
15 |
!TypedArrayTests class methodsFor:'queries'!
|
|
16 |
|
|
17 |
coveredClassNames
|
|
18 |
^ #( FloatArray )
|
|
19 |
! !
|
|
20 |
|
|
21 |
!TypedArrayTests methodsFor:'tests'!
|
|
22 |
|
|
23 |
test01_createArrays
|
|
24 |
|a|
|
|
25 |
|
|
26 |
a := FloatArray new:3.
|
|
27 |
|
|
28 |
self assert:(a size == 3).
|
|
29 |
|
|
30 |
a at:1 put:1.
|
|
31 |
a at:2 put:2.
|
|
32 |
a at:3 put:3.
|
|
33 |
|
|
34 |
self assert:(a at:1) = 1.0.
|
|
35 |
self assert:(a at:2) = 2.0.
|
|
36 |
self assert:(a at:3) = 3.0.
|
1516
|
37 |
|
|
38 |
"/ -------------------------------------
|
|
39 |
|
|
40 |
a := DoubleArray new:3.
|
|
41 |
|
|
42 |
self assert:(a size == 3).
|
|
43 |
|
|
44 |
a at:1 put:1.
|
|
45 |
a at:2 put:2.
|
|
46 |
a at:3 put:3.
|
|
47 |
|
|
48 |
self assert:(a at:1) = 1.0.
|
|
49 |
self assert:(a at:2) = 2.0.
|
|
50 |
self assert:(a at:3) = 3.0.
|
|
51 |
|
|
52 |
"/ -------------------------------------
|
|
53 |
|
|
54 |
a := ByteArray new:3.
|
|
55 |
|
|
56 |
self assert:(a size == 3).
|
|
57 |
|
|
58 |
a at:1 put:1.
|
|
59 |
a at:2 put:2.
|
|
60 |
a at:3 put:3.
|
|
61 |
|
|
62 |
self assert:(a at:1) = 1.
|
|
63 |
self assert:(a at:2) = 2.
|
|
64 |
self assert:(a at:3) = 3.
|
|
65 |
|
|
66 |
"/ -------------------------------------
|
|
67 |
|
|
68 |
a := SignedByteArray new:3.
|
|
69 |
|
|
70 |
self assert:(a size == 3).
|
|
71 |
|
|
72 |
a at:1 put:1.
|
|
73 |
a at:2 put:-2.
|
|
74 |
a at:3 put:3.
|
|
75 |
|
|
76 |
self assert:(a at:1) = 1.
|
|
77 |
self assert:(a at:2) = -2.
|
|
78 |
self assert:(a at:3) = 3.
|
|
79 |
|
|
80 |
"/ -------------------------------------
|
|
81 |
|
|
82 |
a := WordArray new:3.
|
|
83 |
|
|
84 |
self assert:(a size == 3).
|
|
85 |
|
|
86 |
a at:1 put:1.
|
|
87 |
a at:2 put:2.
|
|
88 |
a at:3 put:3.
|
|
89 |
|
|
90 |
self assert:(a at:1) = 1.
|
|
91 |
self assert:(a at:2) = 2.
|
|
92 |
self assert:(a at:3) = 3.
|
|
93 |
|
|
94 |
"/ -------------------------------------
|
|
95 |
|
|
96 |
a := SignedWordArray new:3.
|
|
97 |
|
|
98 |
self assert:(a size == 3).
|
|
99 |
|
|
100 |
a at:1 put:1.
|
|
101 |
a at:2 put:-2.
|
|
102 |
a at:3 put:3.
|
|
103 |
|
|
104 |
self assert:(a at:1) = 1.
|
|
105 |
self assert:(a at:2) = -2.
|
|
106 |
self assert:(a at:3) = 3.
|
|
107 |
|
|
108 |
"/ -------------------------------------
|
|
109 |
|
|
110 |
a := IntegerArray new:3.
|
|
111 |
|
|
112 |
self assert:(a size == 3).
|
|
113 |
|
|
114 |
a at:1 put:1.
|
|
115 |
a at:2 put:2.
|
|
116 |
a at:3 put:3.
|
|
117 |
|
|
118 |
self assert:(a at:1) = 1.
|
|
119 |
self assert:(a at:2) = 2.
|
|
120 |
self assert:(a at:3) = 3.
|
|
121 |
|
|
122 |
"/ -------------------------------------
|
|
123 |
|
|
124 |
a := SignedIntegerArray new:3.
|
|
125 |
|
|
126 |
self assert:(a size == 3).
|
|
127 |
|
|
128 |
a at:1 put:1.
|
|
129 |
a at:2 put:-2.
|
|
130 |
a at:3 put:3.
|
|
131 |
|
|
132 |
self assert:(a at:1) = 1.
|
|
133 |
self assert:(a at:2) = -2.
|
|
134 |
self assert:(a at:3) = 3.
|
|
135 |
|
|
136 |
"/ -------------------------------------
|
|
137 |
|
|
138 |
a := LongIntegerArray new:3.
|
|
139 |
|
|
140 |
self assert:(a size == 3).
|
|
141 |
|
|
142 |
a at:1 put:1.
|
|
143 |
a at:2 put:2.
|
|
144 |
a at:3 put:3.
|
|
145 |
|
|
146 |
self assert:(a at:1) = 1.
|
|
147 |
self assert:(a at:2) = 2.
|
|
148 |
self assert:(a at:3) = 3.
|
|
149 |
|
|
150 |
"/ -------------------------------------
|
|
151 |
|
|
152 |
a := SignedLongIntegerArray new:3.
|
|
153 |
|
|
154 |
self assert:(a size == 3).
|
|
155 |
|
|
156 |
a at:1 put:1.
|
|
157 |
a at:2 put:-2.
|
|
158 |
a at:3 put:3.
|
|
159 |
|
|
160 |
self assert:(a at:1) = 1.
|
|
161 |
self assert:(a at:2) = -2.
|
|
162 |
self assert:(a at:3) = 3.
|
1513
|
163 |
!
|
|
164 |
|
|
165 |
test02_copyArrays
|
|
166 |
|src copy|
|
|
167 |
|
1516
|
168 |
"/ -------------------------------------
|
|
169 |
|
1517
|
170 |
src := FloatArray new:5.
|
|
171 |
self assert:(src size == 5).
|
1515
|
172 |
|
1513
|
173 |
src at:1 put:1.
|
|
174 |
src at:2 put:2.
|
|
175 |
src at:3 put:3.
|
|
176 |
|
|
177 |
self assert:(src at:1) = 1.0.
|
|
178 |
self assert:(src at:2) = 2.0.
|
|
179 |
self assert:(src at:3) = 3.0.
|
|
180 |
|
|
181 |
copy := src copyFrom:1 to:3.
|
|
182 |
|
|
183 |
self assert:(copy size == 3).
|
|
184 |
self assert:(copy at:1) = 1.0.
|
|
185 |
self assert:(copy at:2) = 2.0.
|
|
186 |
self assert:(copy at:3) = 3.0.
|
1516
|
187 |
|
|
188 |
"/ -------------------------------------
|
|
189 |
|
|
190 |
src := DoubleArray new:9.
|
|
191 |
self assert:(src size == 9).
|
|
192 |
|
|
193 |
src at:1 put:1.
|
|
194 |
src at:2 put:2.
|
|
195 |
src at:3 put:3.
|
|
196 |
|
|
197 |
self assert:(src at:1) = 1.0.
|
|
198 |
self assert:(src at:2) = 2.0.
|
|
199 |
self assert:(src at:3) = 3.0.
|
|
200 |
|
|
201 |
copy := src copyFrom:1 to:3.
|
|
202 |
|
|
203 |
self assert:(copy size == 3).
|
|
204 |
self assert:(copy at:1) = 1.0.
|
|
205 |
self assert:(copy at:2) = 2.0.
|
|
206 |
self assert:(copy at:3) = 3.0.
|
|
207 |
|
|
208 |
"/ -------------------------------------
|
|
209 |
|
|
210 |
src := ByteArray new:9.
|
|
211 |
self assert:(src size == 9).
|
|
212 |
|
|
213 |
src at:1 put:1.
|
|
214 |
src at:2 put:2.
|
|
215 |
src at:3 put:3.
|
|
216 |
|
|
217 |
self assert:(src at:1) = 1.
|
|
218 |
self assert:(src at:2) = 2.
|
|
219 |
self assert:(src at:3) = 3.
|
|
220 |
|
|
221 |
copy := src copyFrom:1 to:3.
|
|
222 |
|
|
223 |
self assert:(copy size == 3).
|
|
224 |
self assert:(copy at:1) = 1.
|
|
225 |
self assert:(copy at:2) = 2.
|
|
226 |
self assert:(copy at:3) = 3.
|
|
227 |
|
|
228 |
"/ -------------------------------------
|
|
229 |
|
|
230 |
src := SignedByteArray new:9.
|
|
231 |
self assert:(src size == 9).
|
|
232 |
|
|
233 |
src at:1 put:1.
|
|
234 |
src at:2 put:-2.
|
|
235 |
src at:3 put:3.
|
|
236 |
|
|
237 |
self assert:(src at:1) = 1.
|
|
238 |
self assert:(src at:2) = -2.
|
|
239 |
self assert:(src at:3) = 3.
|
|
240 |
|
|
241 |
copy := src copyFrom:1 to:3.
|
|
242 |
|
|
243 |
self assert:(copy size == 3).
|
|
244 |
self assert:(copy at:1) = 1.
|
|
245 |
self assert:(copy at:2) = -2.
|
|
246 |
self assert:(copy at:3) = 3.
|
|
247 |
|
|
248 |
"/ -------------------------------------
|
|
249 |
|
|
250 |
src := WordArray new:9.
|
|
251 |
self assert:(src size == 9).
|
|
252 |
|
|
253 |
src at:1 put:1.
|
|
254 |
src at:2 put:2.
|
|
255 |
src at:3 put:3.
|
|
256 |
|
|
257 |
self assert:(src at:1) = 1.
|
|
258 |
self assert:(src at:2) = 2.
|
|
259 |
self assert:(src at:3) = 3.
|
|
260 |
|
|
261 |
copy := src copyFrom:1 to:3.
|
|
262 |
|
|
263 |
self assert:(copy size == 3).
|
|
264 |
self assert:(copy at:1) = 1.
|
|
265 |
self assert:(copy at:2) = 2.
|
|
266 |
self assert:(copy at:3) = 3.
|
|
267 |
|
|
268 |
"/ -------------------------------------
|
|
269 |
|
|
270 |
src := SignedWordArray new:9.
|
|
271 |
self assert:(src size == 9).
|
|
272 |
|
|
273 |
src at:1 put:1.
|
|
274 |
src at:2 put:-2.
|
|
275 |
src at:3 put:3.
|
|
276 |
|
|
277 |
self assert:(src at:1) = 1.
|
|
278 |
self assert:(src at:2) = -2.
|
|
279 |
self assert:(src at:3) = 3.
|
|
280 |
|
|
281 |
copy := src copyFrom:1 to:3.
|
|
282 |
|
|
283 |
self assert:(copy size == 3).
|
|
284 |
self assert:(copy at:1) = 1.
|
|
285 |
self assert:(copy at:2) = -2.
|
|
286 |
self assert:(copy at:3) = 3.
|
|
287 |
|
|
288 |
"/ -------------------------------------
|
|
289 |
|
|
290 |
src := IntegerArray new:9.
|
|
291 |
self assert:(src size == 9).
|
|
292 |
|
|
293 |
src at:1 put:1.
|
|
294 |
src at:2 put:2.
|
|
295 |
src at:3 put:3.
|
|
296 |
|
|
297 |
self assert:(src at:1) = 1.
|
|
298 |
self assert:(src at:2) = 2.
|
|
299 |
self assert:(src at:3) = 3.
|
|
300 |
|
|
301 |
copy := src copyFrom:1 to:3.
|
|
302 |
|
|
303 |
self assert:(copy size == 3).
|
|
304 |
self assert:(copy at:1) = 1.
|
|
305 |
self assert:(copy at:2) = 2.
|
|
306 |
self assert:(copy at:3) = 3.
|
|
307 |
|
|
308 |
"/ -------------------------------------
|
|
309 |
|
|
310 |
src := SignedIntegerArray new:9.
|
|
311 |
self assert:(src size == 9).
|
|
312 |
|
|
313 |
src at:1 put:1.
|
|
314 |
src at:2 put:-2.
|
|
315 |
src at:3 put:3.
|
|
316 |
|
|
317 |
self assert:(src at:1) = 1.
|
|
318 |
self assert:(src at:2) = -2.
|
|
319 |
self assert:(src at:3) = 3.
|
|
320 |
|
|
321 |
copy := src copyFrom:1 to:3.
|
|
322 |
|
|
323 |
self assert:(copy size == 3).
|
|
324 |
self assert:(copy at:1) = 1.
|
|
325 |
self assert:(copy at:2) = -2.
|
|
326 |
self assert:(copy at:3) = 3.
|
|
327 |
|
|
328 |
"/ -------------------------------------
|
|
329 |
|
|
330 |
src := LongIntegerArray new:9.
|
|
331 |
self assert:(src size == 9).
|
|
332 |
|
|
333 |
src at:1 put:1.
|
|
334 |
src at:2 put:2.
|
|
335 |
src at:3 put:3.
|
|
336 |
|
|
337 |
self assert:(src at:1) = 1.
|
|
338 |
self assert:(src at:2) = 2.
|
|
339 |
self assert:(src at:3) = 3.
|
|
340 |
|
|
341 |
copy := src copyFrom:1 to:3.
|
|
342 |
|
|
343 |
self assert:(copy size == 3).
|
|
344 |
self assert:(copy at:1) = 1.
|
|
345 |
self assert:(copy at:2) = 2.
|
|
346 |
self assert:(copy at:3) = 3.
|
|
347 |
|
|
348 |
"/ -------------------------------------
|
|
349 |
|
|
350 |
src := SignedLongIntegerArray new:9.
|
|
351 |
self assert:(src size == 9).
|
|
352 |
|
|
353 |
src at:1 put:1.
|
|
354 |
src at:2 put:-2.
|
|
355 |
src at:3 put:3.
|
|
356 |
|
|
357 |
self assert:(src at:1) = 1.
|
|
358 |
self assert:(src at:2) = -2.
|
|
359 |
self assert:(src at:3) = 3.
|
|
360 |
|
|
361 |
copy := src copyFrom:1 to:3.
|
|
362 |
|
|
363 |
self assert:(copy size == 3).
|
|
364 |
self assert:(copy at:1) = 1.
|
|
365 |
self assert:(copy at:2) = -2.
|
|
366 |
self assert:(copy at:3) = 3.
|
1518
|
367 |
!
|
|
368 |
|
|
369 |
test03_byteAt
|
|
370 |
|a flt1 flt2 flt3|
|
|
371 |
|
|
372 |
"/ -------------------------------------
|
|
373 |
|
|
374 |
a := FloatArray new:3.
|
|
375 |
|
|
376 |
a at:1 put:1.
|
|
377 |
a at:2 put:2.
|
|
378 |
a at:3 put:99.
|
|
379 |
|
|
380 |
flt1 := 1 asShortFloat.
|
|
381 |
flt2 := 2 asShortFloat.
|
|
382 |
flt3 := 3 asShortFloat.
|
|
383 |
|
|
384 |
self assert:(a byteAt:1) = (flt1 byteAt:1).
|
|
385 |
self assert:(a byteAt:2) = (flt1 byteAt:2).
|
|
386 |
self assert:(a byteAt:3) = (flt1 byteAt:3).
|
|
387 |
self assert:(a byteAt:4) = (flt1 byteAt:4).
|
|
388 |
|
|
389 |
self assert:(a byteAt:5) = (flt2 byteAt:1).
|
|
390 |
self assert:(a byteAt:6) = (flt2 byteAt:2).
|
|
391 |
self assert:(a byteAt:7) = (flt2 byteAt:3).
|
|
392 |
self assert:(a byteAt:8) = (flt2 byteAt:4).
|
|
393 |
|
|
394 |
a byteAt:5 put:(flt3 byteAt:1).
|
|
395 |
a byteAt:6 put:(flt3 byteAt:2).
|
|
396 |
a byteAt:7 put:(flt3 byteAt:3).
|
|
397 |
a byteAt:8 put:(flt3 byteAt:4).
|
|
398 |
|
|
399 |
self assert:(a at:1) = flt1.
|
|
400 |
self assert:(a at:2) = flt3.
|
|
401 |
self assert:(a at:3) = 99.
|
|
402 |
|
|
403 |
"/ -------------------------------------
|
|
404 |
|
|
405 |
a := DoubleArray new:3.
|
|
406 |
|
|
407 |
a at:1 put:1.
|
|
408 |
a at:2 put:2.
|
|
409 |
a at:3 put:99.
|
|
410 |
|
|
411 |
flt1 := 1 asFloat.
|
|
412 |
flt2 := 2 asFloat.
|
|
413 |
flt3 := 3 asFloat.
|
|
414 |
|
|
415 |
self assert:(a byteAt:1) = (flt1 byteAt:1).
|
|
416 |
self assert:(a byteAt:2) = (flt1 byteAt:2).
|
|
417 |
self assert:(a byteAt:3) = (flt1 byteAt:3).
|
|
418 |
self assert:(a byteAt:4) = (flt1 byteAt:4).
|
|
419 |
self assert:(a byteAt:5) = (flt1 byteAt:5).
|
|
420 |
self assert:(a byteAt:6) = (flt1 byteAt:6).
|
|
421 |
self assert:(a byteAt:7) = (flt1 byteAt:7).
|
|
422 |
self assert:(a byteAt:8) = (flt1 byteAt:8).
|
|
423 |
|
|
424 |
self assert:(a byteAt:9) = (flt2 byteAt:1).
|
|
425 |
self assert:(a byteAt:10) = (flt2 byteAt:2).
|
|
426 |
self assert:(a byteAt:11) = (flt2 byteAt:3).
|
|
427 |
self assert:(a byteAt:12) = (flt2 byteAt:4).
|
|
428 |
self assert:(a byteAt:13) = (flt2 byteAt:5).
|
|
429 |
self assert:(a byteAt:14) = (flt2 byteAt:6).
|
|
430 |
self assert:(a byteAt:15) = (flt2 byteAt:7).
|
|
431 |
self assert:(a byteAt:16) = (flt2 byteAt:8).
|
|
432 |
|
|
433 |
a byteAt:9 put:(flt3 byteAt:1).
|
|
434 |
a byteAt:10 put:(flt3 byteAt:2).
|
|
435 |
a byteAt:11 put:(flt3 byteAt:3).
|
|
436 |
a byteAt:12 put:(flt3 byteAt:4).
|
|
437 |
a byteAt:13 put:(flt3 byteAt:5).
|
|
438 |
a byteAt:14 put:(flt3 byteAt:6).
|
|
439 |
a byteAt:15 put:(flt3 byteAt:7).
|
|
440 |
a byteAt:16 put:(flt3 byteAt:8).
|
|
441 |
|
|
442 |
self assert:(a at:1) = flt1.
|
|
443 |
self assert:(a at:2) = flt3.
|
|
444 |
self assert:(a at:3) = 99.
|
|
445 |
|
|
446 |
"/ -------------------------------------
|
|
447 |
|
|
448 |
a := IntegerArray new:3.
|
|
449 |
|
|
450 |
a at:1 put:1.
|
|
451 |
a at:2 put:2.
|
|
452 |
a at:3 put:99.
|
|
453 |
|
|
454 |
"/ this depends on the machine's byte order!!
|
|
455 |
UninterpretedBytes isBigEndian ifTrue:[
|
|
456 |
self assert:(a byteAt:1) = 0.
|
|
457 |
self assert:(a byteAt:2) = 0.
|
|
458 |
self assert:(a byteAt:3) = 0.
|
|
459 |
self assert:(a byteAt:4) = 1.
|
|
460 |
|
|
461 |
self assert:(a byteAt:5) = 0.
|
|
462 |
self assert:(a byteAt:6) = 0.
|
|
463 |
self assert:(a byteAt:7) = 0.
|
|
464 |
self assert:(a byteAt:8) = 2.
|
|
465 |
|
|
466 |
a byteAt:5 put:(flt3 byteAt:1).
|
|
467 |
a byteAt:6 put:(flt3 byteAt:2).
|
|
468 |
a byteAt:7 put:(flt3 byteAt:3).
|
|
469 |
a byteAt:8 put:(flt3 byteAt:4).
|
|
470 |
|
|
471 |
a byteAt:8 put:3.
|
|
472 |
] ifFalse:[
|
|
473 |
self assert:(a byteAt:1) = 1.
|
|
474 |
self assert:(a byteAt:2) = 0.
|
|
475 |
self assert:(a byteAt:3) = 0.
|
|
476 |
self assert:(a byteAt:4) = 0.
|
|
477 |
|
|
478 |
self assert:(a byteAt:5) = 2.
|
|
479 |
self assert:(a byteAt:6) = 0.
|
|
480 |
self assert:(a byteAt:7) = 0.
|
|
481 |
self assert:(a byteAt:8) = 0.
|
|
482 |
|
|
483 |
a byteAt:5 put:3.
|
|
484 |
].
|
|
485 |
|
|
486 |
self assert:(a at:1) = 1.
|
|
487 |
self assert:(a at:2) = 3.
|
|
488 |
self assert:(a at:3) = 99.
|
|
489 |
|
|
490 |
"/ -------------------------------------
|
|
491 |
|
|
492 |
a := LongIntegerArray new:3.
|
|
493 |
|
|
494 |
a at:1 put:1.
|
|
495 |
a at:2 put:2.
|
|
496 |
a at:3 put:99.
|
|
497 |
|
|
498 |
"/ this depends on the machine's byte order!!
|
|
499 |
UninterpretedBytes isBigEndian ifTrue:[
|
|
500 |
self assert:(a byteAt:1) = 0.
|
|
501 |
self assert:(a byteAt:2) = 0.
|
|
502 |
self assert:(a byteAt:3) = 0.
|
|
503 |
self assert:(a byteAt:4) = 0.
|
|
504 |
self assert:(a byteAt:5) = 0.
|
|
505 |
self assert:(a byteAt:6) = 0.
|
|
506 |
self assert:(a byteAt:7) = 0.
|
|
507 |
self assert:(a byteAt:8) = 1.
|
|
508 |
|
|
509 |
self assert:(a byteAt:8+1) = 0.
|
|
510 |
self assert:(a byteAt:8+2) = 0.
|
|
511 |
self assert:(a byteAt:8+3) = 0.
|
|
512 |
self assert:(a byteAt:8+4) = 0.
|
|
513 |
self assert:(a byteAt:8+5) = 0.
|
|
514 |
self assert:(a byteAt:8+6) = 0.
|
|
515 |
self assert:(a byteAt:8+7) = 0.
|
|
516 |
self assert:(a byteAt:8+8) = 2.
|
|
517 |
|
|
518 |
a byteAt:8+8 put:3.
|
|
519 |
] ifFalse:[
|
|
520 |
self assert:(a byteAt:1) = 1.
|
|
521 |
self assert:(a byteAt:2) = 0.
|
|
522 |
self assert:(a byteAt:3) = 0.
|
|
523 |
self assert:(a byteAt:4) = 0.
|
|
524 |
self assert:(a byteAt:5) = 0.
|
|
525 |
self assert:(a byteAt:6) = 0.
|
|
526 |
self assert:(a byteAt:7) = 0.
|
|
527 |
self assert:(a byteAt:8) = 0.
|
|
528 |
|
|
529 |
self assert:(a byteAt:8+1) = 2.
|
|
530 |
self assert:(a byteAt:8+2) = 0.
|
|
531 |
self assert:(a byteAt:8+3) = 0.
|
|
532 |
self assert:(a byteAt:8+4) = 0.
|
|
533 |
self assert:(a byteAt:8+5) = 0.
|
|
534 |
self assert:(a byteAt:8+6) = 0.
|
|
535 |
self assert:(a byteAt:8+7) = 0.
|
|
536 |
self assert:(a byteAt:8+8) = 0.
|
|
537 |
|
|
538 |
a byteAt:8+1 put:3.
|
|
539 |
].
|
|
540 |
|
|
541 |
self assert:(a at:1) = 1.
|
|
542 |
self assert:(a at:2) = 3.
|
|
543 |
self assert:(a at:3) = 99.
|
|
544 |
|
|
545 |
"/ -------------------------------------
|
1520
|
546 |
|
|
547 |
a := SignedLongIntegerArray new:3.
|
|
548 |
|
|
549 |
a at:1 put:1.
|
|
550 |
a at:2 put:-2.
|
|
551 |
a at:3 put:99.
|
|
552 |
|
|
553 |
"/ this depends on the machine's byte order!!
|
|
554 |
UninterpretedBytes isBigEndian ifTrue:[
|
|
555 |
self assert:(a byteAt:1) = 0.
|
|
556 |
self assert:(a byteAt:2) = 0.
|
|
557 |
self assert:(a byteAt:3) = 0.
|
|
558 |
self assert:(a byteAt:4) = 0.
|
|
559 |
self assert:(a byteAt:5) = 0.
|
|
560 |
self assert:(a byteAt:6) = 0.
|
|
561 |
self assert:(a byteAt:7) = 0.
|
|
562 |
self assert:(a byteAt:8) = 1.
|
|
563 |
|
|
564 |
self assert:(a byteAt:8+1) = 16rFF.
|
|
565 |
self assert:(a byteAt:8+2) = 16rFF.
|
|
566 |
self assert:(a byteAt:8+3) = 16rFF.
|
|
567 |
self assert:(a byteAt:8+4) = 16rFF.
|
|
568 |
self assert:(a byteAt:8+5) = 16rFF.
|
|
569 |
self assert:(a byteAt:8+6) = 16rFF.
|
|
570 |
self assert:(a byteAt:8+7) = 16rFF.
|
|
571 |
self assert:(a byteAt:8+8) = 16rFE.
|
|
572 |
|
|
573 |
a byteAt:8+8 put:16rFD.
|
|
574 |
] ifFalse:[
|
|
575 |
self assert:(a byteAt:1) = 1.
|
|
576 |
self assert:(a byteAt:2) = 0.
|
|
577 |
self assert:(a byteAt:3) = 0.
|
|
578 |
self assert:(a byteAt:4) = 0.
|
|
579 |
self assert:(a byteAt:5) = 0.
|
|
580 |
self assert:(a byteAt:6) = 0.
|
|
581 |
self assert:(a byteAt:7) = 0.
|
|
582 |
self assert:(a byteAt:8) = 0.
|
|
583 |
|
|
584 |
self assert:(a byteAt:8+1) = 16rFE.
|
|
585 |
self assert:(a byteAt:8+2) = 16rFF.
|
|
586 |
self assert:(a byteAt:8+3) = 16rFF.
|
|
587 |
self assert:(a byteAt:8+4) = 16rFF.
|
|
588 |
self assert:(a byteAt:8+5) = 16rFF.
|
|
589 |
self assert:(a byteAt:8+6) = 16rFF.
|
|
590 |
self assert:(a byteAt:8+7) = 16rFF.
|
|
591 |
self assert:(a byteAt:8+8) = 16rFF.
|
|
592 |
|
|
593 |
a byteAt:8+1 put:16rFD.
|
|
594 |
].
|
|
595 |
|
|
596 |
self assert:(a at:1) = 1.
|
|
597 |
self assert:(a at:2) = -3.
|
|
598 |
self assert:(a at:3) = 99.
|
|
599 |
|
1518
|
600 |
"/ -------------------------------------
|
1520
|
601 |
"/ -------------------------------------
|
|
602 |
|
|
603 |
"Modified: / 26-08-2016 / 13:27:57 / cg"
|
1513
|
604 |
! !
|
|
605 |
|
|
606 |
!TypedArrayTests class methodsFor:'documentation'!
|
|
607 |
|
|
608 |
version
|
|
609 |
^ '$Header$'
|
|
610 |
!
|
|
611 |
|
|
612 |
version_CVS
|
|
613 |
^ '$Header$'
|
|
614 |
! !
|
|
615 |
|