Next: , Up: PlUnit A Unit Test Box   [Contents][Index]


10.34.3.1 Determinate Tests

Determinate tests are tests that must succeed exactly once, leaving no choicepoints behind. The test-body supplies proper values for the input arguments and verifies the output arguments. Verification can use test-options or be explicit in the test-body. The tests in the example below are equivalent.

test(add1) :-
        A is 1 + 2,
        A =:= 3.

test(add2, [true(A =:= 3)]) :-
        A is 1 + 2.

The test engine verifies that the test-body does not leave a choicepoint. We illustrate this using the test below:

test(member1) :-
        member(b, [a,b,c]).

Although this test succeeds, member/2 leaves a choicepoint behind, which is reported by the test harness. To make the test silent, use one of the alternatives below.

test(member2) :-
        memberchk(b, [a,b,c]).

test(member3) :-
        member(b, [a,b,c]), !.

test(member4, [nondet]) :-
        member(b, [a,b,c]).

Send feedback on this subject.