Permalink
Browse files

Add failing iterator test

Add the iterator command to the EQC test to prove that it is broken.
  • Loading branch information...
1 parent d56a99b commit 9b068e89f046d0cf52daba98cec29e5dc161fbab @rzezeski rzezeski committed Aug 31, 2012
Showing with 12 additions and 0 deletions.
  1. +12 −0 test/merge_index_tests.erl
@@ -99,6 +99,7 @@ command(S) ->
%% TODO don't hardcode size to 'all'
{call,?MODULE,range, [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,compact, [P]}]).
@@ -149,6 +150,13 @@ postcondition(#state{postings=Postings}, {call,_,fold,_}, {ok, V}) ->
end,
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},
{call,_,lookup,[_,{I,F,T,_,_,_}]}, V) ->
%% TODO This is actually testing the wrong property b/c there is
@@ -299,6 +307,10 @@ info(Pid, {I,F,T,_,_,_}) ->
is_empty(Pid) ->
merge_index:is_empty(Pid).
+iterator(Pid) ->
+ Ft = fun(_,_) -> true end,
+ merge_index:iterator(Pid, Ft).
+
fold(Pid, Fun, Acc) ->
merge_index:fold(Pid, Fun, Acc).

0 comments on commit 9b068e8

Please sign in to comment.