[squeak-dev] Why isn't BlockClosureTest>>testCull failing?

Levente Uzonyi leves at elte.hu
Sun Oct 26 00:35:23 UTC 2014


I think that behavior was changed not too long ago (1-2 years maybe). If 
you decompile the method you'll see that it's actually

 	self
 		assert: 1
 		equals: ([:x | x]
 				cull: 1).

It's because Squeak used to return the value of the last argument if the 
block was empty, but had arguments.
The code should be

 	self assert: nil equals: ([ :x | ] cull: 1).

Levente

On Sat, 25 Oct 2014, David T. Lewis wrote:

> If we have this:
> 	[ :x | ] value: 1 ==> nil
>
> And this:
> 	([ :x | ] cull: 1) ==> nil
>
> But in BlockClosureTest>>testCull, we have this:
>
> 	self assert: 1 equals: ([ :x | ] cull: 1).
>
> The test passes. How is this possible?
>
> If I rewrite that line in the test as follows, then it fails as I would expect:
>
> 	foo := [ :x | ] cull: 1.
> 	self assert: 1 equals: foo.
>
> Ah, but wait. If I revert the test method back to the original, presumably
> recompiling it in the process, the test now fails exactly as I would have
> expected.
>
> The test also fails in the way I would expect in a 68002 format image,
> which is what prompted me to ask the question.
>
> The previous version of #testCull and related tests seem to pass and look
> plausibly correct to me. The current (newer) version looks wrong to me, but
> seems to inexplicably pass until the test is recompiled.
>
> Dave
>
>
>


More information about the Squeak-dev mailing list