-
Notifications
You must be signed in to change notification settings - Fork 6
Open
Description
While reviewing CTQueue, I noticed that two distinct queue instances containing the exact same elements in the same order are not considered equal.
Because CTQueue inherits directly from Object it misses out on the default content-based = and hash methods provided by the Pharo Collection hierarchy. Consequently, equality checks fall back to memory identity (==).
Failing Test to Reproduce:
Adding the following test to CTQueueTest reproduces the issue:
testEquality
| q1 q2 |
q1 := CTQueue new.
q2 := CTQueue new.
q1 enqueue: 'A'; enqueue: 'B'.
q2 enqueue: 'A'; enqueue: 'B'.
self assert: q1 equals: q2.
self assert: q1 hash equals: q2 hash.Proposed Solution:
Implement custom = and hash methods in CTQueue to ensure equality is evaluated based on the queue's size and the ordered contents of its internal elements, rather than its memory address.
I would be happy to open a PR for this!
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels