Skip to content

[stdlib] Review & update hash testing to use Hasher's new features #16066

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Apr 21, 2018

Conversation

lorentey
Copy link
Member

  • Update checkHashable to verify that different values hash differently -- we can do this with hash(into:) because we can eliminate hash collisions by trying different seeds.
  • Switch MinimalHashable* types to use _hash(into:) as the primary hashing interface.

This makes it easier to understand failure traces in test logs.
This is safe to do with hash(into:), because random hash collisions can be eliminated with awesome certainty by trying a number of different hash seeds. (Unless there is a weakness in SipHash.)

In some cases, we intentionally want hashing to produce looser equivalency classes than equality — to let those cases keep working, add an optional hashEqualityOracle parameter.

Review usages of checkHashable and add hash oracles as needed.
This prototype is not fully implemented, and it relies on specific hash values to not trigger unhandled cases.

To keep its test working, define and use a custom hashing interface that emulates hashValue behavior prior to SE-0206.
@lorentey lorentey force-pushed the better-hash-tests branch from 645aa56 to 6984782 Compare April 20, 2018 18:22
@lorentey
Copy link
Member Author

@swift-ci please test

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant