[m-rev.] for review: add a test coverage scenario

Fergus Henderson fjh at cs.mu.OZ.AU
Mon Jul 23 21:14:48 AEST 2001


On 19-Jul-2001, Erwan Jahier <Erwan.Jahier at irisa.fr> wrote:
> Maybe this code is not mature enough (too much XXXs, not enough
> tested), but I would like to commit it before I leave on
> holidays. Any objection?
...
> Add a scenario which provides commands that perform predicate and
> call site coverage.
...
> extras/morphine/INSTALL_MORPHINE:

s/_/-

> Index: extras/morphine/non-regression-tests/queens.exp
> ===================================================================
> RCS file: /home/mercury1/repository/mercury/extras/morphine/non-regression-tests/queens.exp,v
> retrieving revision 1.8
> diff -u -d -u -r1.8 queens.exp
> --- extras/morphine/non-regression-tests/queens.exp	2001/07/05 08:05:36	1.8
> +++ extras/morphine/non-regression-tests/queens.exp	2001/07/19 14:11:16
> @@ -268,6 +268,52 @@
>  Result2 = 38511     More? (;) 
>  [morphine 9]: 
>  **************************************************
> +**** Testing call_site_cov...
> +
> +translating /udd/jahier/mercury/extras/morphine/source/coverage.op
> +/udd/jahier/mercury/extras/morphine/source/coverage.op is translated
> +/udd/jahier/mercury/extras/morphine/bin/generate_call_site_cov queens.m ../../../library/

That test case is only going to pass when it is run in that
specific directory /udd/jahier/...

One way to fix that is to change the Mmakefile so that it
pipes the output of the test through

	sed "s@`pwd`@<current directory>@g"

> +++ coverage.op	Fri Jul 20 00:11:16 2001
> +"Takes a Mercury module name \"Module\", and unifies its 2sd argument with the \

s/2sd/2nd/

Likewise later in this file.

> +uncovered predicate criteria of \"Module\" and the modules it imports which \
> +are in the current directory. A predicate criterion is a \
> +3-uple containing a module name, a procedure name, and a list of `exit' and \

s/3-uple/3-tuple/

Likewise later in this file.

> Index: extras/morphine/source/generate_call_site_cov.m
> ===================================================================
> RCS file: generate_call_site_cov.m
> diff -N generate_call_site_cov.m
> --- /dev/null	Wed Nov 15 09:24:47 2000
> +++ generate_call_site_cov.m	Fri Jul 20 00:11:16 2001
> +%
> +% Generates a monitor that computes the call site list of a Mercury module,
> +% and which generates a monitor (to be run by collect) that performs the
> +% call site coverage.

You generate a monitor which itself then generates another monitor?

> +			    ["*** Warning: No library source files was found",

s/was/were/

> +			     "*** Have you set the 2sd arg of get_call_site",

s/2sd/second/

(The correct abbreviation is "2nd", but it's better to spell it out here.)

> +			     "*** correctly to the Mercury library path?\n"])

"to the correct Mercury library path?" would be better.

> +:- pred is_a_constructor(string::in) is semidet.
> +is_a_constructor(";").
> +is_a_constructor(",").
> +is_a_constructor("{}").
> +is_a_constructor("->").
> +is_a_constructor("if").
> +is_a_constructor("then").
> +is_a_constructor("else").
> +is_a_constructor("=>").
> +is_a_constructor("<=").
> +is_a_constructor("<=>").
> +is_a_constructor("all").
> +is_a_constructor("some").
> +is_a_constructor("not").
> +is_a_constructor("\\+").

You should take the arity into account here.

> +ignore_call("").    % High order function application of the 
> +		    % form: `FuncVar(Arg1, ...)'.  
> +
> +
> +
> +:- pred is_a_high_order_call(string::in) is semidet.
> +is_a_high_order_call("call").  % pred call
> +is_a_high_order_call("apply"). % func call

"" should be treated the same as "call" or "apply".

> +:- pred call_site_to_call_site_crit(list(proc_det)::in, call_site::in, 
> +	call_site_crit::out) is det.
> +call_site_to_call_site_crit(Pdl, Cs, Csc) :-
> +% XXX Actually, there can be more than one solution if several procs
> +% have the same name in different modules. I need the type inference
> +% result to solve that problem. Note that it should not occur too often,
> +% and when it happens, the determinism ougth to be the same 
> +% (e.g., append for lists and strings...)
> +%
> +% XXX It would also require a mode analysis to know in which mode append is
> +% called... Sigh, I should really parse the HLDS ...
> +%
> +% It means that I suppose it works for one mode => one predicate !
> +% 
> +% Well, the false entry probably can be fixed by hand...
> +%

Rather than using promise_only_solution here, when you know it isn't always
the only solution, you should just call solutions/2 and get the first element
of the list (give the called predicate determinism `multi' rather than
`cc_multi').  The XXX comment should stay, but at least you won't be lying
to the compiler...

Likewise for the other calls to `promise_only_solution'
(in call_site_cov.in and pred_cov.in).

-- 
Fergus Henderson <fjh at cs.mu.oz.au>  |  "I have always known that the pursuit
The University of Melbourne         |  of excellence is a lethal habit"
WWW: <http://www.cs.mu.oz.au/~fjh>  |     -- the last words of T. S. Garp.
--------------------------------------------------------------------------
mercury-reviews mailing list
post:  mercury-reviews at cs.mu.oz.au
administrative address: owner-mercury-reviews at cs.mu.oz.au
unsubscribe: Address: mercury-reviews-request at cs.mu.oz.au Message: unsubscribe
subscribe:   Address: mercury-reviews-request at cs.mu.oz.au Message: subscribe
--------------------------------------------------------------------------



More information about the reviews mailing list