
+Goal should_give +CheckGoal

   Run the goal Goal and print a message if Goal and CheckGoal don't succeed

Type
   library(test_util)

Description

    Run the goal Goal and print a message if Goal does not succeed, or
    if the result doesn't satisfy CheckGoal.

    CheckGoal can be an arbitrary user-defined goal.  In this case, the
    first solution of Goal is committed to, and CheckGoal executed with
    the variable instantiations of this solution.

    To allow verification of goals with multiple solutions, one special
    form of CheckGoal is recognised:

	multiple_solutions(SolCountVar, FinalCheck, SolutionCheck)

    where SolCountVar should be a fresh variable.  With such a CheckGoal,
    ALL solutions to Goal will be generated.  For each solution, SolutionCheck
    will be executed with the variable instantiations of this solution, and
    with SolCountVar instantiated to the number of this solution (starting
    from 1).  After all solutions have been found, FinalCheck will be
    executed, with SolCountVar instantiated to the total number of solutions.


Modules
   This predicate is sensitive to its module context (tool predicate, see @/2).

Examples
   
    % Testing deterministic goals

    X is 3.0+4 should_give X=7.0.

    T1=foo(_,_), copy_term(T1,T2) should_give variant(T1,T2).
    

    % Testing nondeterministic goals

    member(X,[a,b,c]) should_give multiple_solutions(K, K==3,
        ( K==1 -> X==a
        ; K==2 -> X==b
        ; K==3 -> X==c
	)).
    

See Also
   should_fail / 1, should_throw / 2, should_raise / 2, should_give / 3, should_fail / 2, should_throw / 3, should_raise / 3
