Testing equality of blocks
Keith Hodges
keith_hodges at yahoo.co.uk
Mon Dec 24 01:29:59 UTC 2007
Tom Phoenix wrote:
> On Dec 23, 2007 3:11 PM, Keith Hodges <keith_hodges at yahoo.co.uk> wrote:
>
>
>> I am wanting to test the equality of blocks, as are the two blocks that
>> I have defined in the same method context.
>>
>
> Are you talking about using #== here? Two blocks are equal if and only
> if they are the same block? Or is there some other kind of block
> equality you're looking for?
>
> --Tom Phoenix
>
According to http://bugs.squeak.org/view.php?id=6599 you can test
BlockClosures for equality.
However I had to define my own test for BlockContext's
This does what I want
BlockContext>>#= other
self class == other class ifFalse: [^ false].
self home receiver == other home receiver ifFalse: [^ false].
self home selector == other home selector ifFalse: [^ false].
^ self startpc == other startpc
TestBlock>>#blocks
^ Array with: [1] with: [1]
TestBlock>>testBlocks
self assert: (self blocks = self blocks).
self deny: (self blocks first = self blocks second).
self deny: (self blocks first == self blocks first). "**"
** a #== comparison will not succeed since although it is actually the same block, the instance of blockContext is different
Keith
More information about the Squeak-dev
mailing list
|