Skip to content

Commit

Permalink
Add failing iterator test
Browse files Browse the repository at this point in the history
Add the iterator command to the EQC test to prove that it is broken.
  • Loading branch information
rzezeski committed Sep 4, 2012
1 parent d56a99b commit 9b068e8
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions test/merge_index_tests.erl
Expand Up @@ -99,6 +99,7 @@ command(S) ->
%% TODO don't hardcode size to 'all' %% TODO don't hardcode size to 'all'
{call,?MODULE,range, [P, g_range_query(Postings), all]}, {call,?MODULE,range, [P, g_range_query(Postings), all]},
{call,?MODULE,range_sync, [P, g_range_query(Postings), all]}, {call,?MODULE,range_sync, [P, g_range_query(Postings), all]},
{call,?MODULE,iterator, [P]},
{call,?MODULE,drop, [P]}, {call,?MODULE,drop, [P]},
{call,?MODULE,compact, [P]}]). {call,?MODULE,compact, [P]}]).


Expand Down Expand Up @@ -149,6 +150,13 @@ postcondition(#state{postings=Postings}, {call,_,fold,_}, {ok, V}) ->
end, end,
ok == ?assert(lists:all(P,V2)); ok == ?assert(lists:all(P,V2));


postcondition(#state{postings=Postings}, {call,_,iterator,_}, V) ->
V2 = lists:sort(iterate(V)),
Postings2 = [{Ii,Ff,Tt,Vv,TS,P} || {Ii,Ff,Tt,Vv,P,TS} <- Postings],
Postings3 = lists:sort(Postings2),
P = fun(E) -> lists:member(E, Postings3) end,
ok == ?assert(lists:all(P, V2));

postcondition(#state{postings=Postings}, postcondition(#state{postings=Postings},
{call,_,lookup,[_,{I,F,T,_,_,_}]}, V) -> {call,_,lookup,[_,{I,F,T,_,_,_}]}, V) ->
%% TODO This is actually testing the wrong property b/c there is %% TODO This is actually testing the wrong property b/c there is
Expand Down Expand Up @@ -299,6 +307,10 @@ info(Pid, {I,F,T,_,_,_}) ->
is_empty(Pid) -> is_empty(Pid) ->
merge_index:is_empty(Pid). merge_index:is_empty(Pid).


iterator(Pid) ->
Ft = fun(_,_) -> true end,
merge_index:iterator(Pid, Ft).

fold(Pid, Fun, Acc) -> fold(Pid, Fun, Acc) ->
merge_index:fold(Pid, Fun, Acc). merge_index:fold(Pid, Fun, Acc).


Expand Down

0 comments on commit 9b068e8

Please sign in to comment.