[squeak-dev] Units package

cdrick cdrick65 at gmail.com
Thu Jun 19 18:22:35 UTC 2008


2008/6/19 Gabriel Cotelli <g.cotelli at gmail.com>:
> Hi,
> I believe is not a good idea to test de denial of two hashes...
> I two objects are equal then the hash must be the same, but te inverse is
> not true

I agree, I wrote this test to show the behavior (and I should have
left the failing test :) ). The hash function is probably not good.

>
> If two objects aren't equal the hash could be the same... and that's ok...
> the number of possible hashes is lesser than the number of possible
> objects...
>
> Why not?
>
> testEquality
>        self deny: (60 units: #seconds) = (60 units: #meters).
>        self assert: (60 units: #seconds) = (1 units: #minutes);
>              assert: (60 units: #seconds) hash = (1 units: #minutes) hash.

the last one fails with the provided hash.

this hash seems ok:

UnitValue>>hash
|baseUnit|

	baseUnit := (self baseUnits).
 	^ baseUnit value hash bitXor: baseUnit unit hash


> Gabriel
>
Thanks ;)

Cédrick


More information about the Squeak-dev mailing list