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

Should be:
isEmpty
    "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

Notes
(0010228)
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).
(0010230)
Damien Cassou   
02-27-07 17:00   
Sorry, I forgot some methods for the tests.
(0010231)
Ron   
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
Ron@USMedRec.com
(0010491)
edgardec   
04-02-07 12:12   
This now is 7076fixPositionableStream-isEmpty.1.cs and was in updates for 3.10
Thanks Damien !
(0010498)
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:

isEmpty
  "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:

isEmpty

  "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.
(0010519)
wiz   
04-11-07 05:00   
see the child problem
(0010522)
Damien Cassou   
04-11-07 06:58   
Linked bug: http://bugs.squeak.org/view.php?id=6405 [^]
(0010523)
edgardec   
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 ...
(0010918)
Damien Cassou   
07-23-07 09:28   
The fix has been included (it's present in 7130 and probably long before).

(0012586)
KenCausey   
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.