Closed Rinzwind closed 2 months ago
Hi Kris,
Great catch, nice analysis, good reproducible example, super fix suggestion.
This is what I ended up with (basically just the highlighted addition). I made the example/test a bit simpler/smaller.
If you agree I will commit this.
Thanks, seems fine!
Thanks, Kris, the fix was pushed
In the following example, the last
#next
message unexpectedly answers 1 rather than 2:This is because
#position:
assumes that the buffer’s end corresponds to the current position of the stream, which is invalidated by the case in which#shouldBufferReadOfCount:
answers false in#readInto:startingAt:count:
as that advances the stream while not reading into the buffer. So it would seem that either the first method should be fixed to use the buffer’s end as determined when the buffer was read, or the case in the second method should be made to reset the buffer.