[squeak-dev] The Trunk: CollectionsTests-eem.219.mcz

Frank Shearar frank.shearar at gmail.com
Thu Jul 17 14:46:58 UTC 2014


On 16 July 2014 23:44,  <commits at source.squeak.org> wrote:
> Eliot Miranda uploaded a new version of CollectionsTests to project The Trunk:
> http://source.squeak.org/trunk/CollectionsTests-eem.219.mcz
>
> ==================== Summary ====================
>
> Name: CollectionsTests-eem.219
> Author: eem
> Time: 16 July 2014, 3:43:48.337 pm
> UUID: 308275d9-8274-498f-9556-09f2e0d63367
> Ancestors: CollectionsTests-nice.218
>
> Fix DictionaryTest>>testKeyAtValue for hashing (i.e. Spur)
>
> =============== Diff against CollectionsTests-nice.218 ===============
>
> Item was changed:
>   ----- Method: DictionaryTest>>testKeyAtValue (in category 'keys and value tests') -----
>   testKeyAtValue
>         "self run: #testKeyAtValue"
>         "self debug: #testKeyAtValue"
>
>         | dict |
>         dict := Dictionary new.
>         dict at: #a put: 1.
>         dict at: #b put: 2.
>         dict at: #c put: 1.
>
>         self assert: (dict keyAtValue: 2) = #b.
> +       "which ever is answered depends on hashing, and hashing is improved in Spur."
> +       self assert: ((dict keyAtValue: 1) = #a or: [(dict keyAtValue: 1) = #c]).
> +       "ugly may be a bug, why not have a set #a and #c?  cuz that would be keys at value."
> -       self assert: (dict keyAtValue: 1) = #c.
> -       "ugly may be a bug, why not having a set #a and #c"
>
>         self should: [dict keyAtValue: 0] raise: Error
>
>
>   !

So this looks, to me at least, to highlight the difference between
testing the implementation and testing the interface: given a
non-bijective mapping, what preimage should you get for a value? Well,
it depends - if you insist on _a_ value rather than _the values_, then
the choice is arbitrary: both #a and #c are consistent with the
semantics, and asserting that _only one_ preimage maps to the value is
actually a bug in the test. Improving the hashing algorithm shouldn't
make a test suddenly fail.

Nice!

frank


More information about the Squeak-dev mailing list