The Trunk: Tests-nice.154.mcz

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

The Trunk: Tests-nice.154.mcz

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

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

Name: Tests-nice.154
Author: nice
Time: 27 July 2012, 8:14:03.431 pm
UUID: fa846130-25ce-4a75-bcee-212b658a274a
Ancestors: Tests-cwp.153

Use a workaround for testBecomeIdentityHash knowing that two objects created consecutively may share same identityHash.

=============== Diff against Tests-cwp.153 ===============

Item was changed:
  ----- Method: BecomeTest>>testBecomeIdentityHash (in category 'Testing') -----
  testBecomeIdentityHash
  | a b c d numberOfRetry newAIdentityHash newBIdentityHash oldAIdentityHash oldBIdentityHash |
  numberOfRetry := 0.
 
  [a := 'ab' copy.
+ c := IdentitySet new: 1000.
  b := 'cd' copy.
+ d := IdentitySet new: 1000.
  "Note: the sets are allocated with enough room to reduce probability that two different hash lead to same slot"
+ "Note2: a & b creation are interleaved with c & d, because some VM allocate the same identityHash for two consecutively created objects"
+ c add: a; add: b.
+ d add: a.
- (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'.
  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!