Mantis - Squeak
Viewing Issue Advanced Details
2273 Collections minor always 11-28-05 21:29 09-08-08 14:58
closed 3.9  
none 3.10  
0002273: PositionableStream >>isEmpty retuns wrong result
Implemented as:
    "Answer whether the receiver's contents has no elements.
    ^position = 0

Should be:
    "Answer whether the receiver's contents has no elements."
    ^collection size = 0

But fixing this exposes a bug in ParagraphEditor >>backspace:
(This can be immediately demonstrated by typing the backspace key in any ParagraphEditor after making the above repair).

Proposed fixes for both are provided in the attached filein.
parent of 0006409closed wiz in 7081 :7076fixPositionableStream-isEmpty.1.cs was wrong fix. Prettyprint broken by it. 
 bugfixes-ktt.1.cs [^] (799 bytes) 11-28-05 21:29
 PositionableStream-isEmpty.1.cs [^] (1,383 bytes) 02-27-07 16:28
 PositionableStream-isEmpty.2.cs [^] (1,795 bytes) 02-27-07 16:59

Damien Cassou   
02-27-07 16:26   
I found it again. And I fixed it too :-) However, I don't see the problem with ParagraphEditor. In my fix, there are 3 tests (one for ReadStream, one for WriteStream, and one for ReadWriteStream).
Damien Cassou   
02-27-07 17:00   
Sorry, I forgot some methods for the tests.
02-27-07 17:07   
Reviewed the code and tests. The solution works for non buffered positionable streams, which includes the streams within the current fixes hiearchy.

The suggested bug in ParagraphEditor does not appear on a 3.9a[7051] image. The problem may have been fixed in 3.9, or the current solution does not cause this error.

I ran the tests and they all pass on a Win XP sp2 box.

I recommend including this in the base image.

Ron Teitelbaum
04-02-07 12:12   
This now is 7076fixPositionableStream-isEmpty.1.cs and was in updates for 3.10
Thanks Damien !
Damien Cassou   
04-07-07 15:16   
Edgar, you choosed the wrong file. You choosed bugfixes-ktt.1.cs which uses the size of the collection. This implementation relies on the size of the collection:

  "Answer whether the receiver's contents has no elements."
  ^collection size = 0

but this is not a solution because a write stream uses a bigger collection than what it really needs (for efficiency reasons).

One of the possible correct implementation is:


  "Answer whether the receiver's contents has no elements."

  "Returns true if both the set of past and future sequence values of
 the receiver are empty. Otherwise returns false"

  ^ self atEnd and: [position = 0]

You should use PositionableStream-isEmpty.2.cs instead. Moreover, it contains tests.
04-11-07 05:00   
see the child problem
Damien Cassou   
04-11-07 06:58   
Linked bug: [^]
04-11-07 11:31   
I seeing 7083. Test are green.

all test have initials dc

#trash: keywords #('trash:')
No odd pritty print...

I HAVE a PositionableStream-isEmpty.2.cs file on my disc

Losted ...
Damien Cassou   
07-23-07 09:28   
The fix has been included (it's present in 7130 and probably long before).

09-08-08 14:58   
bugfixes-ktt.1.cs was harvested with update 7076. PositionableStream-isEmpty.1.cs and PositionableStream-isEmpty.2.cs were harvested with update 7085.