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

Samuel samuelrivas@REDACTED
Tue Jun 3 13:29:16 CEST 2014


Hi,

Why are you using proper at all for this task? If you want exhaustive
testing, just write a tests that goes over all the alternatives. Using
eunit:

new_dict_test_() ->
    DictTypes = [vbisect, dict, orddict],
    [ ?_assert(valid_empty_dict(T, my_dict_module:new(T))) || T <- DictTypes].




On 1 June 2014 01:03, Jay Nelson <jay@REDACTED> wrote:
> 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()), …)
>
> or
>
> ?LET(Dict_Types, proper:enumerate(epode_dict_type()),
>           [test(DT) || DT <- Dict_Types])
>
> Are there any deterministic generators?
>
> jay
>
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://erlang.org/mailman/listinfo/erlang-questions



-- 
Samuel



More information about the erlang-questions mailing list