[m-rev.] diff: new tabling test cases

Zoltan Somogyi zs at cs.mu.OZ.AU
Wed Oct 30 12:41:56 AEDT 2002


tests/tabling/mday.{m,exp}:
tests/tabling/combine.{m,exp}:
	Two test cases for minimal model tabling that we do not yet pass.

tests/tabling/loopcheck_no_loop.{m,exp}:
	A test case for loop checking that we do pass.

tests/tabling/Mmakefile:
	Enable the loopcheck_no_loop test case, and mention but do not enable
	the other two.

cvs diff: Diffing .
Index: Mmakefile
===================================================================
RCS file: /home/mercury1/repository/tests/tabling/Mmakefile,v
retrieving revision 1.17
diff -u -b -r1.17 Mmakefile
--- Mmakefile	17 Aug 2002 13:52:28 -0000	1.17
+++ Mmakefile	30 Oct 2002 01:34:39 -0000
@@ -15,6 +15,7 @@
 	fib_list \
 	fib_string \
 	loopcheck \
+	loopcheck_no_loop \
 	unused_args
 
 NONDET_PROGS = \
@@ -30,10 +31,12 @@
 
 # We don't yet pass the following minimal model tests. The reason is that
 # they contain interactions between tabling and constructs that function
-# as negated contexts.
+# as commited or negated contexts.
 #
 #	consumer_in_commit
 #	consumer_in_solutions
+#	combine
+#	mday
 
 # Tabling does not yet work in .rt grades
 ifneq "$(findstring .gc,$(GRADE))" ""
Index: combine.exp
===================================================================
RCS file: combine.exp
diff -N combine.exp
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ combine.exp	30 Oct 2002 01:33:49 -0000
@@ -0,0 +1 @@
+[35, 36, 45, 46]
Index: combine.m
===================================================================
RCS file: combine.m
diff -N combine.m
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ combine.m	30 Oct 2002 01:36:51 -0000
@@ -0,0 +1,38 @@
+:- module combine.
+	
+:- interface.
+
+:- import_module io.
+
+:- pred main(io__state::di, io__state::uo) is det.
+
+:- implementation.
+
+:- import_module int, std_util.
+
+main -->
+	{ solutions(a, Solns) },
+	io__write(Solns),
+	io__nl.
+
+:- pred a(int::out) is nondet.
+:- pred b(int::out) is multi.
+:- pred c(int::out) is multi.
+:- pred d(int::out) is nondet.
+
+:- pragma minimal_model(d/1).
+
+a(A) :-
+	d(B),
+	d(C),
+	A = B * 10 + C.
+
+d(A) :-
+	b(A),
+	c(A).
+
+b(3).
+b(4).
+
+c(5).
+c(6).
Index: loopcheck_no_loop.exp
===================================================================
RCS file: loopcheck_no_loop.exp
diff -N loopcheck_no_loop.exp
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ loopcheck_no_loop.exp	2 Oct 2002 15:48:31 -0000
@@ -0,0 +1,2 @@
+6
+3
Index: loopcheck_no_loop.m
===================================================================
RCS file: loopcheck_no_loop.m
diff -N loopcheck_no_loop.m
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ loopcheck_no_loop.m	30 Oct 2002 01:38:25 -0000
@@ -0,0 +1,30 @@
+% Check that loopcheck isn't overzealous.
+
+:- module loopcheck_no_loop.
+:- interface.
+:- import_module io.
+
+:- pred main(io__state::di, io__state::uo) is det.
+
+:- implementation.
+
+:- import_module int.
+
+main -->
+	{ sum(3, Sum3) },
+	io__write_int(Sum3),
+	io__write_string("\n"),
+	{ sum(2, Sum2) },
+	io__write_int(Sum2),
+	io__write_string("\n").
+
+:- pragma loop_check(sum/2).
+:- pred sum(int::in, int::out) is det.
+
+sum(N, SumN) :-
+	( N = 0 ->
+		SumN = 0
+	;
+		sum(N - 1, Sum1),
+		SumN = Sum1 + N
+	).
Index: mday.exp
===================================================================
RCS file: mday.exp
diff -N mday.exp
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ mday.exp	30 Oct 2002 01:34:09 -0000
@@ -0,0 +1 @@
+yes
Index: mday.m
===================================================================
RCS file: mday.m
diff -N mday.m
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ mday.m	5 Oct 2002 01:30:07 -0000
@@ -0,0 +1,39 @@
+:- module mday.
+	
+:- interface.
+
+:- import_module io.
+
+:- pred main(io__state::di, io__state::uo) is det.
+
+:- implementation.
+
+main(IO0, IO) :-
+	( a(_) ->
+		write_string("yes\n", IO0, IO)
+	;
+		write_string("no\n", IO0, IO)
+	).
+
+:- pred a(int::out) is nondet.
+:- pred b(int::out) is multi.
+:- pred c(int::out) is multi.
+:- pred d(int::out) is det.
+:- pred a1(int::out) is nondet.
+:- pred a2(int::out) is nondet.
+
+:- pragma minimal_model(a1/1).
+:- pragma minimal_model(a2/1).
+
+a(A) :- a2(A), d(A).
+
+a2(A) :- a1(A), a1(A).
+a1(A) :- b(A), c(A).
+
+b(3).
+b(4).
+
+c(4).
+c(3).
+
+d(3).
--------------------------------------------------------------------------
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