The Trunk: KernelTests-nice.378.mcz

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

The Trunk: KernelTests-nice.378.mcz

commits-2
Nicolas Cellier uploaded a new version of KernelTests to project The Trunk:
http://source.squeak.org/trunk/KernelTests-nice.378.mcz

==================== Summary ====================

Name: KernelTests-nice.378
Author: nice
Time: 25 April 2020, 3:19:51.367541 pm
UUID: c233a5e2-d02d-4010-a59a-441c4e1f9c25
Ancestors: KernelTests-eem.377

Assert that we can use once more than once.

#once is using startpc as a key to register the value of first evaluation.
This works well for old block closure whose bytecode lie in homeMethod at different startpc.
But the startpc of FullBlockClosure might all be equal...

So it's far from obvious that once is going to work for Full blocks.
But #once is using startpc the inst.var. rather than #startpc the message send.
And the startpc inst. var. contains the CompiledBlock which is misleading.

Since I've been bitten more than once, I prefer to document it.

There is a little flaw though: two equal blocks will register at same key...
Maybe there's no real use case, but we might want to use an IdentityDictionary as cache.

=============== Diff against KernelTests-eem.377 ===============

Item was added:
+ ----- Method: BlockClosureTest>>testMoreThanOnce (in category 'tests - evaluating') -----
+ testMoreThanOnce
+ "Make sure that we can use once more than once"
+ | moreThanOnce |
+ moreThanOnce := (1 to: 3) collect: [:e | [String new] once -> [Array new] once].
+ self assert: (moreThanOnce allSatisfy: [:each | each key isString]).
+ self assert: (moreThanOnce allSatisfy: [:each | each value isArray]).
+ self assert: (moreThanOnce allSatisfy: [:each | each key == moreThanOnce first key]).
+ self assert: (moreThanOnce allSatisfy: [:each | each value == moreThanOnce first value]).!

Item was added:
+ ----- Method: BlockClosureTest>>testMoreThanOnceForEqualBlocks (in category 'tests - evaluating') -----
+ testMoreThanOnceForEqualBlocks
+ "Make sure that we can use once more than once"
+ | moreThanOnce |
+ moreThanOnce := (1 to: 3) collect: [:e | [Object new] once -> [Object new] once].
+ self assert: (moreThanOnce allSatisfy: [:each | each key == moreThanOnce first key]).
+ self assert: (moreThanOnce allSatisfy: [:each | each value == moreThanOnce first value]).
+ self assert: (moreThanOnce noneSatisfy: [:each | each key == each value]).!