[Pkg] The Trunk: Tests-nice.142.mcz

commits at source.squeak.org commits at source.squeak.org
Tue Feb 21 14:00:59 UTC 2012


Nicolas Cellier uploaded a new version of Tests to project The Trunk:
http://source.squeak.org/trunk/Tests-nice.142.mcz

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

Name: Tests-nice.142
Author: nice
Time: 21 February 2012, 3:00:38.727 pm
UUID: 6af7860f-3bab-4beb-890b-c8bebe9a2b31
Ancestors: Tests-nice.141

Depending on the VM, I have testBecomeIdentityHash sometimes failing...
As the test was not very expressive, I rewrote it to explain the purpose of identityHash preservation,.
Doing so, I also isolated the bad behaviour description previously tested:

   The VM is spawning too many equal identityHash to be honest

This happens on my COG version and this might require further analysis...

=============== Diff against Tests-nice.141 ===============

Item was changed:
  ----- Method: BecomeTest>>testBecomeIdentityHash (in category 'Testing') -----
  testBecomeIdentityHash
+ 	| a b c d numberOfRetry newAIdentityHash newBIdentityHash oldAIdentityHash oldBIdentityHash |
+ 	numberOfRetry := 0.
+ 	
+ 	[a := 'ab' copy.
- 	"Note. The identity hash of both objects seems to change after the become:"
- 
- 	| a b c d |
- 
- 	a := 'ab' copy.
  	b := 'cd' copy.
+ 	"Note: the sets are allocated with enough room to reduce probability that two different hash lead to same slot"
+ 	(c := IdentitySet new: 1000) add: a; add: b.
+ 	(d := IdentitySet new: 1000) add: a.
+ 	oldAIdentityHash := a identityHash.
+ 	oldBIdentityHash := b identityHash.
+ 	oldAIdentityHash = oldBIdentityHash and: [numberOfRetry < 10]]
+ 		whileTrue: [numberOfRetry := numberOfRetry + 1].
+ 	self assert: oldAIdentityHash ~= oldBIdentityHash description: 'The VM is spawning too many equal identityHash to be honest'.
- 	c := a.
- 	d := b.
- 
  	a become: b.
+ 	newAIdentityHash := a identityHash.
+ 	newBIdentityHash := b identityHash.
+ 	self
+ 		"The set c & d can still retrieve their elements because elements did not change their expected position"
+ 		assert: (c includes: a);
+ 		assert: (c includes: b);
+ 		assert: (d includes: a);
+ 		deny: (d includes: b);
+ 		"Elements didn't change their expected position because identityHash did not change"
+ 		assert: oldAIdentityHash = newAIdentityHash;
+ 		assert: oldBIdentityHash = newBIdentityHash!
- 
- 	self 
- 		assert: a identityHash = c identityHash;
- 		assert: b identityHash = d identityHash;
- 		deny: a identityHash = b identityHash.
- !



More information about the Packages mailing list