Well, the bloks collected in collection should all refer to the same temporary variable | index | in the context of execution of testWhileModificationBeforeNotInlined When these get executed by assertValues:, we can expect they all return the current value of this | index | temp, that is 5. That is not the case, because BlockClosure implementation creates a copy of outside temporaries it accesses (this is for optimization purposes). You can try to fool the compiler with this code: | index block | index := 0. block := [ index := index + 1. collection add: [ 1>2 ifTrue: [index:=0]. index ] ]. [ index < 5 ] whileTrue: block. There you get #(5 5 5 5 5) as expected... I suggest this test be moved in known failures. Lukas ? Nicolas 2009/6/17 Gabriel Cotelli <g.cotelli@gmail.com>
Doing some test fixing I noticed that testWhileModificationBeforeNotInlined not fail.... but I think it should be:
Here is the code:
testWhileModificationBeforeNotInlined
| index block | index := 0. block := [ index := index + 1. collection add: [ index ] ]. [ index < 5 ] whileTrue: block. self assertValues: #(5 5 5 5 5)
I think this should produce in collection: #(1 2 3 4 5) ... there's another tests with the block directly as collaborator of the whileTrue: (without temp assignment) that produces the expected output...
I'm missing something?
Thanks Gabriel
_______________________________________________ Pharo-project mailing list Pharo-project@lists.gforge.inria.fr http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project