Some test code:
:- begin_tests(member).
% Standard success
test(t1, true, [nondet]) :- member(1,[1,2,3]).
% Succeed twice
test(t2, all(X == [1,1])) :- X=1, member(X,[1,2,3,1]).
% Succeed even if the "list" is a non-list, as long as the prefix contains 1
test(t3, true, [nondet]) :- L=[1,2,3|nope], \+is_list(L), member(1,L).
:- end_tests(member).
rt(member) :- run_tests(member).
When we load this:
?- [member_test].
Warning: /home/me/member_test.pl:13:
Warning: Clauses of plunit_member:test/3 are not together in the source-file
Warning: Earlier definition at /home/me/member_test.pl:5
Warning: Current predicate: plunit_member:'unit body'/2
Warning: Use :- discontiguous plunit_member:test/3. to suppress this message
true.
Is this is expected? It might be best to suppress this warning, right?
Alternatively, I can apparently write this, (second-guessing the documentation), inserting true
before all
:
test(t2, true, all(X == [1,1])) :- X=1, member(X,[1,2,3,1]).
Then everything is test/3
and the compiler does not warn.