2.2 Writing the test body
AllApplicationManualNameSummaryHelp

  • Documentation
    • Reference manual
    • Packages
      • Prolog Unit Tests
        • A Unit Test box
          • Writing the test body
            • Testing deterministic predicates
            • Testing semi-deterministic predicates
            • Testing non-deterministic predicates
            • Testing error conditions
            • One body with multiple tests using assertions

2.2.2 Testing semi-deterministic predicates

Semi-deterministic predicates are predicates that either fail or succeed exactly once and, for well behaved predicates, leave no choicepoints. Testing such predicates is the same as testing deterministic predicates. Negative tests must be specified using the option fail or by negating the body using \+/1.

test(is_set) :-
        \+ is_set([a,a]).

test(is_set, [fail]) :-
        is_set([a,a]).