[squeak-dev] RawBitsArray vs. DataStream

Nicolas Cellier nicolas.cellier.aka.nice at gmail.com
Tue Nov 22 14:45:38 UTC 2022


Le mar. 22 nov. 2022 à 14:01, Marcel Taeumel <marcel.taeumel at hpi.de> a
écrit :

> Hi Eliot --
>
> > The test worked second time for me ...
>
> Well, you wrote a test that does not account for the example I provided in
> my first e-mail. ;-) Maybe I used the wrong API. I combined #nextPut: with
> #nextArray. Looks reasonable to me.
>
> The code in DataStreamTest looks scary: #testObject: #get: #put:
> #unStream: #streamedRepresentationOf: ... oh my ...
>
>
Well, you have used readArray which is marked as private in comment, and
will fail because we did not write an Array...
(i would recommend to classify those methods in a private category/protocol)
The example should use next instead, in which case it works for me.


> Best,
> Marcel
>
> Am 22.11.2022 13:57:19 schrieb Eliot Miranda <eliot.miranda at gmail.com>:
>
>
> On Tue, Nov 22, 2022 at 4:54 AM Marcel Taeumel <marcel.taeumel at hpi.de>
> wrote:
>
>> Hi Eliot --
>>
>> > Write a test :-)
>>
>> My image freezes. It seems totally broken. That's why I asked. I wanted
>> to learn more about the expected behavior. After that, I could write a
>> test. ;-)
>>
>
> Interesting! The test worked second time for me (I used "instance first
> class = Color", which is false since in that case "instance first class =
> TransparentColor :-) ). That's 64 bits macOS.
>
> Are you seeing this on 32-bit Windows? or...?
>
>
>
>> Best,
>> Marcel
>>
>> Am 22.11.2022 13:50:30 schrieb Eliot Miranda <eliot.miranda at gmail.com>:
>> Hi Marcel,
>>
>> On Tue, Nov 22, 2022 at 1:58 AM Marcel Taeumel <marcel.taeumel at hpi.de>
>> wrote:
>>
>>> Hi all --
>>>
>>> Should the following work?
>>>
>>> class := DoubleByteArray.
>>> size := 10.
>>> dummy := 123.
>>>
>>> array := class new: size.
>>> array  atAllPut: dummy.
>>>
>>> (DataStream newFileNamed: 'numbers')
>>> nextPut: array;
>>> close.
>>>
>>> stream := DataStream fileNamed: 'numbers'.
>>> load := stream readArray.
>>> stream close.
>>> load explore
>>>
>>
>> Write a test :-)
>>
>> testRawBits
>>     ((RawBitsArray subclasses reject: #isAbstract), ((RawBitsArray
>> subclasses select: #isAbstract) collect: #subclasses)) flatten do:
>>         [:class| | instance |
>>         instance := class new: 10.
>>         instance first isColor
>>             ifTrue:
>>                 [1 to: instance size do: [:i| instance at: i put: (Color
>> r: i * 1 g: i * 2 b: i * 3)]]
>>             ifFalse:
>>                 [1 to: instance size do: [:i| instance at: i put: i]].
>>         self assert: instance equals: (self testObject: instance)
>> description: 'A ', class name, ' should be serializable']
>>
>> see Tests-eem.494
>>
>>
>>> Best,
>>> Marcel
>>>
>>>
>>
>> --
>> _,,,^..^,,,_
>> best, Eliot
>>
>>
>>
>
> --
> _,,,^..^,,,_
> best, Eliot
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20221122/9f6083c4/attachment.html>


More information about the Squeak-dev mailing list