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.
- !
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.
- !
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.
- !
Nicolas Cellier uploaded a new version of Graphics to project The Trunk:
http://source.squeak.org/trunk/Graphics-nice.192.mcz
==================== Summary ====================
Name: Graphics-nice.192
Author: nice
Time: 20 February 2012, 7:30:30.765 pm
UUID: 47abe0e7-0db5-4c46-9fc2-b01316877379
Ancestors: Graphics-cmm.191
Fix one of the issues at http://code.google.com/p/pharo/issues/detail?id=5335
self assert: (Color fromString: 'darkGray') = Color darkGray.
=============== Diff against Graphics-cmm.191 ===============
Item was changed:
----- Method: Color class>>fromString: (in category 'instance creation') -----
fromString: aString
"for HTML color spec: #FFCCAA or white/black"
"Color fromString: '#FFCCAA'.
Color fromString: 'white'.
Color fromString: 'orange'"
| aColorHex |
aString isEmptyOrNil ifTrue: [ ^self white ].
aString first = $#
ifTrue: [ aColorHex := aString allButFirst ]
ifFalse: [ aColorHex := aString ].
(aColorHex size = 6 and: [
aColorHex allSatisfy: [ :each | '0123456789ABCDEFabcdef' includes: each ] ])
ifTrue: [
| green red blue |
red := (Integer readFrom: (aColorHex first: 2) base: 16) / 255.
green := (Integer readFrom: (aColorHex copyFrom: 3 to: 4) base: 16) / 255.
blue := (Integer readFrom: (aColorHex last: 2) base: 16) / 255.
^self r: red g: green b: blue ].
+ "try to match aColorHex with known named colors, case insensitive"
+ ^self perform: (ColorNames detect: [:colorSymbol | aColorHex sameAs: colorSymbol] ifNone: [ #white ])!
- "try to match aColorHex with known named colors"
- ^self perform: (ColorNames like: aColorHex asLowercase ifAbsent: [ #white ])!