Re: The Inbox: CollectionsTests-dtl.418.mcz
| Newsgroups | gmane.comp.lang.smalltalk.squeak.general |
|---|---|
| Message-ID | <[email protected]> |
My long term trunk working image had several corrupt SharedQueue instances with huge internal contents arrays. I still do not know how they got that way, although I expect it was related to my interrupting the queue access methods on various error conditions. Be that as it may, I wrote these tests to help me understand how the queue contents management works. I don't know if these tests should go into trunk because they cover private internal behavior. But if no one says otherwise, I'll move them to trunk in a couple of days because well, why not. Dave On 2026-04-29 22:19, [email protected] wrote: > A new version of CollectionsTests was added to project The Inbox: > http://source.squeak.org/inbox/CollectionsTests-dtl.418.mcz > > ==================== Summary ==================== > > Name: CollectionsTests-dtl.418 > Author: dtl > Time: 29 April 2026, 6:19:17.620474 pm > UUID: fb5879fe-7134-4f8c-a9f9-13dd4d448cbd > Ancestors: CollectionsTests-ct.417 > > SharedQueueTest methods to document the management of the internal > contents array in a SharedQueue, which will grow and contract as > needed. The tests cover private internal behavior, and will fail if > private method #makeRoomAtEnd is changed. > > =============== Diff against CollectionsTests-ct.417 =============== > > Item was added: > + ----- Method: SharedQueueTest>>testMakeRoomAtEndLargerArrayWrapAround > (in category 'tests') ----- > + testMakeRoomAtEndLargerArrayWrapAround > + | queue | > + queue := self queueClass new. > + self assert: (queue instVarNamed: #contentsArray) size = 10 > + description: 'initial contentsArray has size 10'. > + 18 timesRepeat: [queue nextPut: #something]. > + 18 timesRepeat: [queue nextOrNil]. > + queue nextPut: #ONE. > + queue nextPut: #TWO. > + self assert: (queue instVarNamed: #contentsArray) size = 20 > + description: 'contentsArray has grown to size 20'. > + self assert: (queue instVarNamed: #writePosition) = 21. > + "next insert will trigger makeRoomAtBeginning" > + queue nextPut: #THREE. > + self assert: (queue instVarNamed: #contentsArray) size = 10 > + description: 'new contentsArray with smaller size sufficient > for queue contents'. > + self assert: (queue instVarNamed: #writePosition) = 4. "wrapped > around in new small collection" > + self assert: (queue instVarNamed: #readPosition) = 1. > + "verify nothing lost from the queue after running > makeRoomAtBeginning" > + self assert: #ONE equals: queue nextOrNil. > + self assert: #TWO equals: queue nextOrNil. > + self assert: #THREE equals: queue nextOrNil. > + self assert: nil equals: queue nextOrNil. > + self assert: 0 equals: queue size. > + ! > > Item was added: > + ----- Method: SharedQueueTest>>testMakeRoomAtEndSmallArrayExtend (in > category 'tests') ----- > + testMakeRoomAtEndSmallArrayExtend > + | queue | > + queue := self queueClass new. > + self assert: (queue instVarNamed: #contentsArray) size = 10 > + description: 'initial contentsArray has size 10'. > + 8 timesRepeat: [queue nextPut: #something]. > + queue nextPut: #ONE. > + queue nextPut: #TWO. > + self assert: (queue instVarNamed: #contentsArray) size = 10 > + description: 'using initial contentsArray with size 10'. > + self assert: (queue instVarNamed: #writePosition) = 11. > + "next insert will trigger makeRoomAtBeginning" > + queue nextPut: #THREE. > + self assert: (queue instVarNamed: #contentsArray) size = 20 > + description: 'new contentsArray, size has been doubled'. > + self assert: (queue instVarNamed: #writePosition) = 12. > + "verify nothing lost from the queue after running > makeRoomAtBeginning" > + 8 timesRepeat: [self assert: #something equals: queue nextOrNil]. > + self assert: #ONE equals: queue nextOrNil. > + self assert: #TWO equals: queue nextOrNil. > + self assert: #THREE equals: queue nextOrNil. > + self assert: nil equals: queue nextOrNil. > + self assert: 0 equals: queue size. > + ! > > Item was added: > + ----- Method: SharedQueueTest>>testMakeRoomAtEndSmallArrayWrapAround > (in category 'tests') ----- > + testMakeRoomAtEndSmallArrayWrapAround > + | queue | > + queue := self queueClass new. > + self assert: (queue instVarNamed: #contentsArray) size = 10 > + description: 'initial contentsArray has size 10'. > + 8 timesRepeat: [queue nextPut: #something]. > + 8 timesRepeat: [queue nextOrNil]. > + queue nextPut: #ONE. > + queue nextPut: #TWO. > + self assert: (queue instVarNamed: #contentsArray) size = 10 > + description: 'using initial contentsArray with size 10'. > + self assert: (queue instVarNamed: #writePosition) = 11. > + "next insert will trigger makeRoomAtBeginning" > + queue nextPut: #THREE. > + self assert: (queue instVarNamed: #contentsArray) size = 10 > + description: 'initial contentsArray has room, continue using > it'. > + self assert: (queue instVarNamed: #writePosition) = 4. "wrapped > around in same collection" > + self assert: (queue instVarNamed: #readPosition) = 1. > + "verify nothing lost from the queue after running > makeRoomAtBeginning" > + self assert: #ONE equals: queue nextOrNil. > + self assert: #TWO equals: queue nextOrNil. > + self assert: #THREE equals: queue nextOrNil. > + self assert: nil equals: queue nextOrNil. > + self assert: 0 equals: queue size. > + ! > > Item was added: > + ----- Method: SharedQueueTest>>testMakeRoomAtEndVeryLargeArrayExtend > (in category 'tests') ----- > + testMakeRoomAtEndVeryLargeArrayExtend > + | queue | > + queue := self queueClass new: 10000. > + self assert: (queue instVarNamed: #contentsArray) size = 10000 > + description: 'large initiaol contentsArray'. > + 9998 timesRepeat: [queue nextPut: #something]. > + 400 timesRepeat: [queue nextOrNil]. > + queue nextPut: #ONE. > + queue nextPut: #TWO. > + self assert: (queue instVarNamed: #contentsArray) size = 10000 > + description: 'contentsArray filled to end'. > + self assert: (queue instVarNamed: #writePosition) = 10001. > + "next insert will trigger makeRoomAtBeginning" > + queue nextPut: #THREE. > + self assert: (queue instVarNamed: #contentsArray) size = 20000 > + description: 'new contentsArray with smaller size sufficient > for queue contents'. > + self assert: (queue instVarNamed: #writePosition) = 9602. > "wrapped around in new collection of increased size" > + self assert: (queue instVarNamed: #readPosition) = 1. > + "verify nothing lost from the queue after running > makeRoomAtBeginning" > + 9998 - 400 timesRepeat: [self assert: #something equals: queue > nextOrNil]. > + self assert: #ONE equals: queue nextOrNil. > + self assert: #TWO equals: queue nextOrNil. > + self assert: #THREE equals: queue nextOrNil. > + self assert: nil equals: queue nextOrNil. > + self assert: 0 equals: queue size. > + ! > > Item was added: > + ----- Method: > SharedQueueTest>>testMakeRoomAtEndVeryLargeArrayWrapAround (in category > 'tests') ----- > + testMakeRoomAtEndVeryLargeArrayWrapAround > + | queue | > + queue := self queueClass new: 10000. > + self assert: (queue instVarNamed: #contentsArray) size = 10000 > + description: 'large initiaol contentsArray'. > + 9998 timesRepeat: [queue nextPut: #something]. > + 9998 timesRepeat: [queue nextOrNil]. > + queue nextPut: #ONE. > + queue nextPut: #TWO. > + self assert: (queue instVarNamed: #contentsArray) size = 10000 > + description: 'contentsArray filled to end'. > + self assert: (queue instVarNamed: #writePosition) = 10001. > + "next insert will trigger makeRoomAtBeginning" > + queue nextPut: #THREE. > + self assert: (queue instVarNamed: #contentsArray) size = 10 > + description: 'new contentsArray with smaller size sufficient > for queue contents'. > + self assert: (queue instVarNamed: #writePosition) = 4. "wrapped > around in new small collection" > + self assert: (queue instVarNamed: #readPosition) = 1. > + "verify nothing lost from the queue after running > makeRoomAtBeginning" > + self assert: #ONE equals: queue nextOrNil. > + self assert: #TWO equals: queue nextOrNil. > + self assert: #THREE equals: queue nextOrNil. > + self assert: nil equals: queue nextOrNil. > + self assert: 0 equals: queue size. > + ! > > Squeak-dev mailing list -- [email protected] > To unsubscribe send an email to > [email protected] Squeak-dev mailing list -- [email protected] To unsubscribe send an email to [email protected]