RFR: 8285295: Need better testing for IdentityHashMap

Stuart Marks smarks at openjdk.java.net
Wed Apr 27 03:24:17 UTC 2022


On Fri, 22 Apr 2022 03:37:27 GMT, Stuart Marks <smarks at openjdk.org> wrote:

> Basic but fairly comprehensive set of tests for `IdentityHashMap`. The patch in the bug report that breaks `IdentityHashMap` now causes several cases in this new test to fail. There's more that could be done, but the new tests cover most of the core functions of `IdentityHashMap`. Unfortunately it seems difficult to merge this with the existing, comprehensive Collections tests (e.g., MOAT.java) because those tests implicity rely on `equals()`-based contract instead of the special-purpose `==`-based contract used by `IdentityHashMap`.

Probably the same file. It would be nice to be able to re-use some general Set and Collection tests, but the identity semantics make this difficult to do without extensive refactoring.

**

Oh wait, `removeAll` and `retainAll` use the membership contract of the argument, not those of this collection. The current keySet/values/entrySet tests test `toArray` and `contains`, which seems almost sufficient. Well, maybe tests for `remove` on these view collections would be helpful, but I think that's about it.

-------------

PR: https://git.openjdk.java.net/jdk/pull/8354


More information about the core-libs-dev mailing list