[squeak-dev] RawBitsArray vs. DataStream

Marcel Taeumel marcel.taeumel at hpi.de
Tue Nov 22 13:00:49 UTC 2022


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 ...

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 [mailto: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 [mailto:eliot.miranda at gmail.com]>:
Hi Marcel,


On Tue, Nov 22, 2022 at 1:58 AM Marcel Taeumel <marcel.taeumel at hpi.de [mailto: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/8e1ebe08/attachment.html>


More information about the Squeak-dev mailing list