A new version of MultilingualTests was added to project The Inbox: http://source.squeak.org/inbox/MultilingualTests-cbc.46.mcz
==================== Summary ====================
Name: MultilingualTests-cbc.46 Author: cbc Time: 29 December 2023, 1:45:44.450425 pm UUID: 89cddb39-9b8f-144d-8ddb-a8635c12f231 Ancestors: MultilingualTests-cbc.45
Fix to MultiByteFileStreamTest>>testPeek (convert so that tests will actually try to check string against string instead of byteArray against string).
=============== Diff against MultilingualTests-cbc.45 ===============
Item was changed: ----- Method: MultiByteFileStreamTest>>testPeek (in category 'tests') ----- testPeek | fileName | fileName := 'fooPeek.txt'. MultiByteFileStream forceNewFileNamed: fileName do: [ :file | file nextPutAll: '12345678' ]. "Testing when ASCII" MultiByteFileStream oldFileNamed: fileName do: [ :file | self assert: '1234' = (file peek: 4). self assert: '1234' = (file peek: 4). "This fails in vanilla 6.0!!" ]. "Testing when BINARY" MultiByteFileStream oldFileNamed: fileName do: [ :file | file binary. + self assert: '1234' = (file peek: 4) asString. + self assert: '1234' = (file peek: 4) asString. "This fails in vanilla 6.0!!" - self assert: '1234' = (file peek: 4). - self assert: '1234' = (file peek: 4). "This fails in vanilla 6.0!!" ]. !
Hi. I am working with binary MultiByteFileStreams and noticed that #peek: doesn't work right in those cases.
In particular, if the stream is file, then the following isn't true: (file peek: 4) = (file peek: 4) Instead, the file appears to get the next 4 bytes and does NOT reset its position.
Note that for ascii (non-binary) this seems to work just fine.
For my purpose, I've altered PositionableStream>>peek: to use #position and #position: instead of direct access to the position variable. This seems to make it work right - but I'm not convinced that is the right choice in general.
(Also, #peek seems to be weird here for Binary - it gets the next Character/WideCharacter, and if it is a character, returns the asciiValue - else it returns the WideCharacter. That just seems wrong somehow.)
Thanks, Chris
On Fri, Dec 29, 2023 at 1:46 PM commits@source.squeak.org wrote:
A new version of MultilingualTests was added to project The Inbox: http://source.squeak.org/inbox/MultilingualTests-cbc.46.mcz
==================== Summary ====================
Name: MultilingualTests-cbc.46 Author: cbc Time: 29 December 2023, 1:45:44.450425 pm UUID: 89cddb39-9b8f-144d-8ddb-a8635c12f231 Ancestors: MultilingualTests-cbc.45
Fix to MultiByteFileStreamTest>>testPeek (convert so that tests will actually try to check string against string instead of byteArray against string).
=============== Diff against MultilingualTests-cbc.45 ===============
Item was changed:
----- Method: MultiByteFileStreamTest>>testPeek (in category 'tests')
testPeek | fileName | fileName := 'fooPeek.txt'. MultiByteFileStream forceNewFileNamed: fileName do: [ :file | file nextPutAll: '12345678' ]. "Testing when ASCII" MultiByteFileStream oldFileNamed: fileName do: [ :file | self assert: '1234' = (file peek: 4). self assert: '1234' = (file peek: 4). "This fails in vanilla 6.0!!" ]. "Testing when BINARY" MultiByteFileStream oldFileNamed: fileName do: [ :file | file binary.
self assert: '1234' = (file peek: 4) asString.
self assert: '1234' = (file peek: 4) asString. "This fails
in vanilla 6.0!!"
self assert: '1234' = (file peek: 4).
self assert: '1234' = (file peek: 4). "This fails in
vanilla 6.0!!" ]. !
squeak-dev@lists.squeakfoundation.org