Re: [eclipse-users] Unit testing in eclipse prolog

From: Joachim Schimpf (Independent Contractor) <jschimpf_at_cisco.com>
Date: Tue, 05 Jun 2007 22:53:11 +0100
Malcolm Ryan wrote:
> On 10/05/2007, at 8:12 PM, Joachim Schimpf (Independent Contractor) wrote:
> 
>> Malcolm Ryan wrote:
>>> Does anyone have experience with using unit testing tools for prolog?
>>
>> We use the ECLiPSe library test_util
>> http://www.eclipse-clp.org/doc/bips/lib/test_util/index.html
> 
> How would you test something which is supposed to backtrack and give 
> multiple solutions, eg member(X, [a,b,c])?

The obvious way would be to use findall/3, i.e.

   findall(X,member(X,[a,b,c]),Sols) should_give Sols==[a,b,c].

If variable identity matters, you need bagof/3, e.g.

   bagof(X, member(X,[A,B,C]), Sols) should_give Sols==[A,B,C].

I don't think having special support for nondeterministic goals
would simplify things much, am I wrong?


> Oh, and why isn't there a should_succeed (== should_give true)?

Occam's razor - it only saves two keystrokes, but we have to document
a whole new predicate :-)


-- Joachim
Received on Tue Jun 05 2007 - 22:53:29 CEST

This archive was generated by hypermail 2.2.0 : Thu Feb 02 2012 - 02:31:58 CET