Provide your functions. Typically something like the below example.
Note: you can opt out of testing some functions with Nothing, but beware: not
providing eg. toList will result in almost no tests being actually ran.
-- Debug.toString
{ dictToString = Debug.toString
-- Creation
, empty = Just <| OpaqueDict.empty identity
, singleton = Just <| OpaqueDict.singleton identity
, fromList = Just <| OpaqueDict.fromList identity
-- Updating
, insert = Just OpaqueDict.insert
, update = Just OpaqueDict.update
, remove = Just OpaqueDict.remove
, map = Just OpaqueDict.map
, filter = Just OpaqueDict.filter
, union = Just OpaqueDict.union
, intersect = Just OpaqueDict.intersect
, diff = Just OpaqueDict.diff
-- Querying
, size = Just OpaqueDict.size
, isEmpty = Just OpaqueDict.isEmpty
, member = Just OpaqueDict.member
, get = Just OpaqueDict.get
, toList = Just OpaqueDict.toList
, foldl = Just OpaqueDict.foldl
, foldr = Just OpaqueDict.foldr
, partition = Just OpaqueDict.partition
, keys = Just OpaqueDict.keys
, values = Just OpaqueDict.values
, merge = Just OpaqueDict.merge
}
Given a record of your Dict functions, this function will run a comprehensive suite of tests against them, comparing them to the elm/core Dict.
It will:
empty,singletonorfromList)insert,filter,diffetc.)size,get,partition,toListetc.)The process above will run on both your Dict and the
elm/coreDict in tandem. (The same commands will run for both.)There should be no visible difference in behaviour: eg. order of items given from
toListshould be the same.This helps prevent subtle surprises when users switch between Dict implementations, like
update key (\_ -> Nothing)not removing items from the Dict (a real bug in one of the 3rd-party Dicts!).