[erlang-questions] PropEr testing of a fixed set of atoms

Jay Nelson jay@REDACTED
Sun Jun 1 01:03:54 CEST 2014

All the PropEr documentation seems to indicate that only random generators
are possible when testing. Maybe I’m missing something obvious, but I would
like to do a simple exhaustive test on the following example:

-type epode_dict_type() :: vbisect | dict | orddict.
-spec is_dict(epode_dict_type(), any()) -> boolean().

I currently do the following to test it, assuming 6 tries will oversample the set of
three values and nearly always test all three cases:

-define(TM, my_dict_module).

check_new_dict() ->
       Test_New = ?FORALL(Dict_Type, epode_dict_type(),
                                             valid_empty_dict(Dict_Type, ?TM:new(Dict_Type)),
       proper:quickcheck(Test_New, [{num_tests, 6}]).

valid_empty_dict(Dict_Type, Dict) ->
    true = ?TM:is_dict(Dict_Type, Dict),
    0 =:= ?TM:size(Dict).

I would like a deterministic generator that would provide a list of all the dictionary
types. I want to be able to update only the epode_dict_type() and have the test
automatically execute for the new types.

I imagine something like:

?FORALL(Dict_Type, proper:enumerate(epode_dict_type()), …)


?LET(Dict_Types, proper:enumerate(epode_dict_type()),
          [test(DT) || DT <- Dict_Types])

Are there any deterministic generators?


More information about the erlang-questions mailing list