Hi

I have run into two issues when #reset-ing WriteStreams. The first one
is that #reset on WriteStream and ReadWriteStream don't have the same
semantics [1] (although ReadWriteStream is a subclass of WriteStream).

(WriteStream on: String new)
    nextPutAll: 'the content';
    reset;
    contents

gives you ''

but

(ReadWriteStream on: String new)
    nextPutAll: 'the content';
    reset;
    contents

gives you 'the content'

The second is that #reset doesn't affect the answer of #size [2].

WriteStream >> #size has no comment (!) so my naïve assumption of its
semantics are:

aStream size = aStream contents size

However the following test fails:

| stream |
stream := String new writeStream.
self assert: stream size = stream contents size.
stream
        nextPutAll: 'abc';
        reset.
self assert: stream size = stream contents size


 [1] http://code.google.com/p/pharo/issues/detail?id=4706
 [2] http://code.google.com/p/pharo/issues/detail?id=4707

Cheers
Philippe


Reply via email to