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

From: Joachim Schimpf (Independent Contractor) <"Joachim>
Date: Thu, 28 Jun 2007 21:21:22 +0200
Malcolm Ryan wrote:
> On a related topic, I have a notification port on the variable which  
> is notified whenever the set is extended. I would like to add unit  
> tests that ensure that this is being called appropriately. Any  
> suggestions for how to do this?

The generic_sets.ecl file exports a predicate watch/1 which
attaches a demon to a set variable such that every domain
modification gets printed.

For units test you probably don't want to use I/O, but
you could define (for ic_sets) something simpler like:

     start_log(_Var{int_sets:Attr}, Receiver) ?-
	Receiver = rec(_),
	open_receiver(added of int_sets, Attr, 1, Receiver).

     get_log(Receiver, Msgs) :-
	receive_notifications(Receiver, Msgs, _Status).

and then write tests like

   X :: []..[1,2,3],
   start_log(X, RecX),
   3 in X,
   X = [1, 3],
   get_log(RecX, LogX)
should_give
   LogX == [3, 1].

i.e. get a list of all notifications received during
the computation, and check if it is what you expect.


-- Joachim
Received on Thu Jun 28 2007 - 20:21:41 CEST

This archive was generated by hypermail 2.3.0 : Thu Feb 22 2024 - 18:13:19 CET