[m-rev.] for review: Add a post-process predicate in collect
Erwan Jahier
Erwan.Jahier at irisa.fr
Thu Jul 5 02:13:26 AEST 2001
| On 04-Jul-2001, Erwan Jahier <Erwan.Jahier at irisa.fr> wrote:
| >
| > Add a post-process predicate in collect. This predicate is optional
| > and automatically added if the collect user do not define it.
|
| That looks fine, although a test case for it in the Morphine test suite
| might be a good idea.
Indeed... As a matter of fact, that change breaks the suite. Here is the
diff to fix the problem plus a new test case.
--- logmsg.save Wed Jul 4 18:03:28 2001
+++ logmsg Wed Jul 4 18:05:54 2001
@@ -27,3 +27,12 @@
collect__post_process/2) to the accumulator variable before
sending the collect result.
+extras/morphine/non-regression-tests/solutions:
+ Replace collected_type by accumulator_type.
+
+extras/morphine/non-regression-tests/queens.exp:
+extras/morphine/non-regression-tests/queens.in:
+extras/morphine/non-regression-tests/test_ln:
+ Add a new test case entry to test line numbers and the use of
+ post_process/2 with collect.
+
Index: extras/morphine/non-regression-tests/solutions
===================================================================
RCS file: /home/mercury1/repository/mercury/extras/morphine/non-regression-tests/solutions,v
retrieving revision 1.2
diff -u -d -u -r1.2 solutions
--- extras/morphine/non-regression-tests/solutions 2000/08/16 08:50:47 1.2
+++ extras/morphine/non-regression-tests/solutions 2001/07/04 15:52:49
@@ -1,5 +1,5 @@
%------------------------------------------------------------------------------%
-% Copyright (C) 1999-2000 INRIA/INSA.
+% Copyright (C) 1999-2001 INRIA/INSA.
%
% Author : Erwan Jahier <jahier at irisa.fr>
%
@@ -7,8 +7,10 @@
:- import_module list.
-:- type collected_type == list(solutions).
+:- type accumulator_type == list(solutions).
:- type solutions ---> sol(procedure, arguments).
initialize([]).
ndex: extras/morphine/non-regression-tests/queens.in
===================================================================
RCS file: /home/mercury1/repository/mercury/extras/morphine/non-regression-tests/queens.in,v
retrieving revision 1.6
diff -u -d -u -r1.6 queens.in
--- extras/morphine/non-regression-tests/queens.in 2001/06/22 15:20:28 1.6
+++ extras/morphine/non-regression-tests/queens.in 2001/07/04 15:52:49
@@ -182,7 +182,10 @@
rerun,
set_parameter(collect_arg, [yes]),
collect(solutions, Result),
- writeq(Result),
+ writeq(Result), nl, nl,
+ rerun,
+ collect(test_ln, Result2),
+ writeq(Result2),
write("\n*** collect: ok.\n").
Index: extras/morphine/non-regression-tests/test_ln
===================================================================
RCS file: test_ln
diff -N test_ln
--- /dev/null Wed Nov 15 09:24:47 2000
+++ test_ln Thu Jul 5 02:01:57 2001
@@ -0,0 +1,16 @@
+:- import_module int.
+
+:- type accumulator_type == list(int).
+:- type collected_type == int.
+
+initialize([]).
+
+filter(Event, L, [line_number(Event)|L], continue).
+
+
+post_process(List, Int) :-
+ foldl(plus_pred, List, 0, Int).
+
+:- pred plus_pred(int::in, int::in, int::out) is det.
+plus_pred(X, Y, Z) :-
+ Z = plus(X, Y).
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.7
diff -u -d -u -r1.7 queens.exp
--- extras/morphine/non-regression-tests/queens.exp 2001/06/22 15:20:27 1.7
+++ extras/morphine/non-regression-tests/queens.exp 2001/07/04 16:09:19
@@ -255,9 +255,17 @@
+
+run(./, queens, )
+Start debugging queens program.
+ 1: 1 [1] call main(state('<<c_pointer>>'), -) [] 0
+[1, 3, 5, 2, 4]
+End of connection with the traced program
+38511
*** collect: ok.
-Result = [sol(proc(predicate, "queens", "main", 2, 0), [univ_cons(state('<<c_pointer>>'))]), sol(proc(predicate, "queens", "print_list", 3, 0), [univ_cons([1, 3, 5, 2, 4]), univ_cons(state('<<c_pointer>>'))]), sol(proc(predicate, "queens", "print_list_2", 3, 0), [univ_cons([1, 3, 5, 2, 4]), univ_cons(state('<<c_pointer>>'))]), sol(proc(predicate, "queens", "print_list_2", 3, 0), [univ_cons([3, 5, 2, 4]), univ_cons(state('<<c_pointer>>'))]), sol(proc(predicate, "queens", "print_list_2", 3, 0), [univ_cons([5, 2, 4]), univ_cons(state('<<c_pointer>>'))]), sol(proc(predicate, "queens", "print_list_2", 3, 0), [univ_cons([2, 4]), univ_cons(state('<<c_pointer>>'))]), sol(proc(predicate, "queens", "print_list_2", 3, 0), [univ_cons([4]), univ_cons(state('<<c_pointer>>'))]), sol(proc(predicate, "queens", "queen", 2, 0), [univ_cons([1, 2, 3, 4, 5]), univ_cons([1, 3, 5, 2, 4])]), sol(proc(predicate, "queens", "safe", 1, 0), [univ_cons([1, 3, 5, 2, 4])]), sol(proc(predicate, "queens", "s!
afe", 1, 0), [univ_cons([3, 5, 2, 4])]), sol(proc(predicate, "queens", "safe", 1, 0), [univ_cons([5, 2, 4])]), sol(proc(predicate, "queens", "safe", 1, 0), [univ_cons([2, 4])]), sol(proc(predicate, "queens", "safe", 1, 0), [univ_cons([4])]), sol(proc(predicate, "queens", "safe", 1, 0), [univ_cons([])]), sol(proc(predicate, "queens", "nodiag", 3, 0), [univ_cons(4), univ_cons(1), univ_cons(...)]), sol(proc(predicate, "queens", "nodiag", 3, 0), [univ_cons(2), univ_cons(...), ...]), sol(proc(predicate, "queens", "nodiag", 3, 0), [univ_cons(...), ...]), sol(proc(...), [...]), sol(...), ...] More? (;)
+Result = [sol(proc(predicate, "queens", "main", 2, 0), [univ_cons(state('<<c_pointer>>'))]), sol(proc(predicate, "queens", "print_list", 3, 0), [univ_cons([1, 3, 5, 2, 4]), univ_cons(state('<<c_pointer>>'))]), sol(proc(predicate, "queens", "print_list_2", 3, 0), [univ_cons([1, 3, 5, 2, 4]), univ_cons(state('<<c_pointer>>'))]), sol(proc(predicate, "queens", "print_list_2", 3, 0), [univ_cons([3, 5, 2, 4]), univ_cons(state('<<c_pointer>>'))]), sol(proc(predicate, "queens", "print_list_2", 3, 0), [univ_cons([5, 2, 4]), univ_cons(state('<<c_pointer>>'))]), sol(proc(predicate, "queens", "print_list_2", 3, 0), [univ_cons([2, 4]), univ_cons(state('<<c_pointer>>'))]), sol(proc(predicate, "queens", "print_list_2", 3, 0), [univ_cons([4]), univ_cons(state('<<c_pointer>>'))]), sol(proc(predicate, "queens", "queen", 2, 0), [univ_cons([1, 2, 3, 4, 5]), univ_cons([1, 3, 5, 2, 4])]), sol(proc(predicate, "queens", "safe", 1, 0), [univ_cons([1, 3, 5, 2, 4])]), sol(proc(predicate, "queens", "s!
afe", 1, 0), [univ_cons([3, 5, 2, 4])]), sol(proc(predicate, "queens", "safe", 1, 0), [univ_cons([5, 2, 4])]), sol(proc(predicate, "queens", "safe", 1, 0), [univ_cons([2, 4])]), sol(proc(predicate, "queens", "safe", 1, 0), [univ_cons([4])]), sol(proc(predicate, "queens", "safe", 1, 0), [univ_cons([])]), sol(proc(predicate, "queens", "nodiag", 3, 0), [univ_cons(4), univ_cons(1), univ_cons(...)]), sol(proc(predicate, "queens", "nodiag", 3, 0), [univ_cons(2), univ_cons(...), ...]), sol(proc(predicate, "queens", "nodiag", 3, 0), [univ_cons(...), ...]), sol(proc(...), [...]), sol(...), ...]
+Result2 = 38511 More? (;)
[morphine 9]:
**************************************************
**** Testing other Morphine commands...
--
R1.
--------------------------------------------------------------------------
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