I just want to announce a small library that provides tests for your data structure implementations.
Right now it’s just
Dict, but I’d like to extend it to other data structures.
CommonTests.isDict will check and how it works underneath is comparison to
elm/core Dict behaviour. We run the same actions on your Dict implementation and on the core Dict, and then check they arrived at the same results. (a.k.a. model based testing.)
The Dict API is conceptually separated into three categories:
Updates: anything that takes a Dict and returns a Dict.
Queries: anything that returns a non-Dict.
All of which are randomized and tested.
I’ve built on top of @miniBill’s work regarding categorizing the various Dict implementations, and went on to test them with this package. Here are the results:
|Library||Module||Behaves like elm/core Dict?|
|pzp1997/assoc-list||AssocList||Uses insertion order |
The test results above seem to say, we’re doing pretty good!
But again, these test results check conformance to
elm/core Dict behaviour. We should check it as well! Some unit tests do exist already, but we could write some property based tests to perhaps help uncover some more bugs. (Indeed there are some.)
If anybody feels compelled to work on that Dict test suite with me (might be a nice intro to property based tests), send me a message somewhere! We can brainstorm the properties together and then implement them.
This is not necessarily a bug, but it’s a difference from elm/core Dict. It might be unexpected behaviour for those depending on Dicts being sorted by keys. ↩︎
Not that this one in particular could be caught by an unit/property-based test suite: it only shows up with
I can’t promise PRs to
elm/corebeing merged, of course ↩︎