[m-dev.] diff: update accumulator tests

Peter Ross petdr at cs.mu.OZ.AU
Wed Apr 12 19:44:08 AEST 2000


===================================================================


Estimated hours taken: 1

Update the tests to handle the new accumulator introduction module.

general/accumulator/INTRODUCED:
    The new module doesn't yet handle chains of commutative and
    associative calls, so chain:pc no longer has accumulators
    introduced.

general/accumulator/Mmakefile:
    Add the new commutative module to the tests.

general/accumulator/commutative.exp:
general/accumulator/commutative.m:
    Test that accumulators don't get introduced when the predicate is
    commutative but *not* associative.

warnings/arg_order_rearrangment.exp:
    The new algorithm reports a warning with the swapped variables in
    the other order, update the expected output to reflect this.

Index: general/accumulator/INTRODUCED
===================================================================
RCS file: /home/staff/zs/imp/tests/general/accumulator/INTRODUCED,v
retrieving revision 1.1
diff -u -r1.1 INTRODUCED
--- general/accumulator/INTRODUCED	1999/06/16 06:19:15	1.1
+++ general/accumulator/INTRODUCED	2000/01/12 06:27:49
@@ -1,7 +1,6 @@
 	% mode  0 `base:AccFrom__pred__p__23__0/4' (det):
 	% mode  0 `call_in_base:AccFrom__pred__l__23__0/4' (det):
 	% mode  0 `chain:AccFrom__pred__pa__39__0/4' (det):
-	% mode  0 `chain:AccFrom__pred__pc__67__0/4' (det):
 	% mode  0 `construct:AccFrom__pred__p2__46__0/5' (det):
 	% mode  0 `dcg:AccFrom__pred__p__38__0/7' (det):
 	% mode  0 `disj:AccFrom__pred__p__47__0/3' (multi):
Index: general/accumulator/Mmakefile
===================================================================
RCS file: /home/staff/zs/imp/tests/general/accumulator/Mmakefile,v
retrieving revision 1.10
diff -u -r1.10 Mmakefile
--- general/accumulator/Mmakefile	2000/04/05 06:12:02	1.10
+++ general/accumulator/Mmakefile	2000/04/11 08:09:21
@@ -19,6 +19,7 @@
 PROGS=		base		\
 		call_in_base	\
 		chain		\
+		commutative	\
 		construct	\
 		deconstruct	\
 		dcg		\
Index: general/accumulator/commutative.exp
===================================================================
RCS file: commutative.exp
diff -N commutative.exp
--- /dev/null	Thu Mar  4 04:20:11 1999
+++ commutative.exp	Wed Mar 29 16:42:05 2000
@@ -0,0 +1 @@
+p: a
Index: general/accumulator/commutative.m
===================================================================
RCS file: commutative.m
diff -N commutative.m
--- /dev/null	Thu Mar  4 04:20:11 1999
+++ commutative.m	Wed Mar 29 16:41:22 2000
@@ -0,0 +1,45 @@
+% Implementation of a commutative predicate which is not associative,
+% it should not have accumulators introduced.
+
+:- module commutative.
+
+:- interface.
+
+:- import_module io.
+
+:- pred main(io__state::di, io__state::uo) is det.
+
+:- implementation.
+
+:- import_module list.
+
+:- type t ---> a ; b ; c.
+
+main -->
+	io__write_string("p: "),
+	{ p([a,b,c], R) },
+	io__write(R),
+	io__nl.
+
+:- pred p(list(t)::in, t::out) is det.
+
+p([], a).
+p([H|T], R) :-
+	p(T, R0),
+	c(H, R0, R).
+
+	% We define the operator c which is commutative, but
+	% not associative.
+:- pred c(t::in, t::in, t::out) is det.
+
+:- promise all [A,B,C] ( c(A, B, C) <=> c(B, A, C) ).
+
+c(a, a, a).
+c(a, b, a).
+c(a, c, c).
+c(b, a, a).
+c(b, b, b).
+c(b, c, b).
+c(c, a, c).
+c(c, b, b).
+c(c, c, c).

Index: warnings/arg_order_rearrangment.exp
===================================================================
RCS file: /home/staff/zs/imp/tests/warnings/arg_order_rearrangment.exp,v
retrieving revision 1.2
diff -u -r1.2 arg_order_rearrangment.exp
--- warnings/arg_order_rearrangment.exp	2000/01/10 05:11:57	1.2
+++ warnings/arg_order_rearrangment.exp	2000/03/30 12:03:25
@@ -1,8 +1,8 @@
 arg_order_rearrangment.m:008: In predicate `arg_order_rearrangment:r/2'
 arg_order_rearrangment.m:014:   warning: the call to predicate
 arg_order_rearrangment.m:014:     `arg_order_rearrangment:app/3' has had the
-arg_order_rearrangment.m:014:     location of the variables R0 and V_7 swapped
-arg_order_rearrangment.m:014:     to allow accumulator introduction.
+arg_order_rearrangment.m:014:     location of the variables `V_7' and `R0'
+arg_order_rearrangment.m:014:     swapped to allow accumulator introduction.
 arg_order_rearrangment.m:008:   Please ensure that these argument
 arg_order_rearrangment.m:008:     rearrangements do not introduce performance
 arg_order_rearrangment.m:008:     problems. These warnings can be suppressed by

----
Peter Ross
PhD Student University of Melbourne
http://www.cs.mu.oz.au/~petdr/
--------------------------------------------------------------------------
mercury-developers mailing list
Post messages to:       mercury-developers at cs.mu.oz.au
Administrative Queries: owner-mercury-developers at cs.mu.oz.au
Subscriptions:          mercury-developers-request at cs.mu.oz.au
--------------------------------------------------------------------------



More information about the developers mailing list