[m-rev.] diff: add tests for cyclic insts/modes

Fergus Henderson fjh at cs.mu.OZ.AU
Fri Nov 22 19:55:12 AEDT 2002


I'm working on a patch to fix this properly, as per Mark's suggestions
in the thread "fix infinite loop for `:- inst x == x.'"

But in the mean time, here's the additions to the test suite.

----------

Estimated hours taken: 1.5
Branches: main, release

Ensure that the test suite tests for cyclic and undefined insts and modes.

tests/invalid/Mmakefile:
tests/invalid/undef_inst.m:
tests/invalid/undef_inst.err_exp:
	Add a test case for undefined insts.

tests/invalid/Mmakefile:
tests/invalid/circ_inst.m:
tests/invalid/circ_inst2.m:
tests/invalid/circ_inst3.m:
tests/invalid/circ_inst4.m:
tests/invalid/circ_mode.m
tests/invalid/circ_mode2.m
tests/invalid/circ_mode3.m
tests/invalid/circ_mode4.m
	Add test cases for cyclic insts and modes.
	Currently these tests are disabled, since we don't pass them.

Workspace: /home/mars/fjh/ws1/mercury
Index: tests/invalid/Mmakefile
===================================================================
RCS file: /home/mercury1/repository/tests/invalid/Mmakefile,v
retrieving revision 1.129
diff -u -d -r1.129 Mmakefile
--- tests/invalid/Mmakefile	8 Nov 2002 16:24:16 -0000	1.129
+++ tests/invalid/Mmakefile	22 Nov 2002 08:45:16 -0000
@@ -123,6 +123,7 @@
 	type_spec \
 	unbound_type_vars \
 	undef_lambda_mode \
+	undef_inst \
 	undef_mode \
 	undef_mode_and_no_clauses \
 	undef_symbol \
@@ -160,6 +161,10 @@
 #			the type class name should be in quotes)
 #	typeclass_mode_{2,3,4} (compiler calls error/1)
 #	cyclic_typeclass (compiler goes into an infinite loop)
+#	circ_inst{,2} (error is not detected)
+#	circ_inst{3,4} (compiler goes into an infinite loop)
+#	circ_mode{,2} (error is not detected)
+#	circ_mode{3,4} (compiler goes into an infinite loop)
 #	ho_default_func_4 (due to a bug in the mode-checker ---
 #			see XXX comment in inst_match:inst_matches_final_3)
 #	inst_matches_final_bug (due to same bug as ho_default_func_4)
Index: tests/invalid/circ_inst.m
===================================================================
RCS file: tests/invalid/circ_inst.m
diff -N tests/invalid/circ_inst.m
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ tests/invalid/circ_inst.m	22 Nov 2002 08:18:05 -0000
@@ -0,0 +1,11 @@
+% Test for circular equivalence insts.
+:- module circ_inst.
+
+:- interface.
+
+:- inst circ == circ.
+
+:- inst circ1 == circ2.
+
+:- inst circ2 == circ1.
+
Index: tests/invalid/circ_inst2.m
===================================================================
RCS file: tests/invalid/circ_inst2.m
diff -N tests/invalid/circ_inst2.m
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ tests/invalid/circ_inst2.m	22 Nov 2002 08:18:12 -0000
@@ -0,0 +1,20 @@
+% Abother test for circular equivalence insts.
+% This test is similar to circ_inst.m but tests some more
+% complicated cases involving parametric insts.
+
+:- module circ_inst2.
+
+:- interface.
+:- import_module list.
+
+:- inst circ1(I) == circ1(I).			% error -- cyclic
+:- inst circ2(I) == circ2(circ2(I)).		% error -- cyclic
+:- inst circ3(I) == list_skel(circ3(I)).	% OK
+:- inst circ4(I) == circ4(list_skel(I)).	% OK
+
+:- inst left(I) == right(I).			% error -- cyclic
+:- inst right(I) == left(I).			% error -- cyclic
+
+:- inst circ_left(I) == circ_right(list_skel(I)).	% OK
+:- inst circ_right(I) == list_skel(circ_left(I)).	% OK
+
Index: tests/invalid/circ_inst3.m
===================================================================
RCS file: tests/invalid/circ_inst3.m
diff -N tests/invalid/circ_inst3.m
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ tests/invalid/circ_inst3.m	22 Nov 2002 08:18:55 -0000
@@ -0,0 +1,19 @@
+% Test for circular equivalence insts.
+% This is the same as circ_inst.m,
+% except that we also have a predicate which makes use of the insts.
+
+:- module circ_inst3.
+
+:- interface.
+
+:- inst circ == circ.
+
+:- inst circ1 == circ2.
+
+:- inst circ2 == circ1.
+
+:- pred p(int, int, int, int).
+:- mode p(in(circ), out(circ), in(circ1), out(circ2)) is det.
+
+:- implementation.
+p(X, X, Y, Y).
Index: tests/invalid/circ_inst4.m
===================================================================
RCS file: tests/invalid/circ_inst4.m
diff -N tests/invalid/circ_inst4.m
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ tests/invalid/circ_inst4.m	22 Nov 2002 08:19:21 -0000
@@ -0,0 +1,29 @@
+% Abother test for circular equivalence insts.
+% This test is the same as circ_inst2.m except that we
+% also have a predicate which makes use of the insts.
+
+:- module circ_inst4.
+
+:- interface.
+:- import_module list.
+
+:- inst circ1(I) == circ1(I).			% error -- cyclic
+:- inst circ2(I) == circ2(circ2(I)).		% error -- cyclic
+:- inst circ3(I) == list_skel(circ3(I)).	% OK
+:- inst circ4(I) == circ4(list_skel(I)).	% OK
+
+:- inst left(I) == right(I).			% error -- cyclic
+:- inst right(I) == left(I).			% error -- cyclic
+
+:- inst circ_left(I) == circ_right(list_skel(I)).	% OK
+:- inst circ_right(I) == list_skel(circ_left(I)).	% OK
+
+:- pred p(int, int, int, int, int, int, int, int).
+:- mode p(in(circ1(ground)), out(circ2(ground)),
+	in(circ3(ground)), out(circ4(ground)),
+	in(left(ground)), out(right(ground)),
+	in(circ_left(ground)), out(circ_right(ground)))
+	is det.
+
+:- implementation.
+p(A, A, B, B, C, C, D, D).
Index: tests/invalid/undef_inst.err_exp
===================================================================
RCS file: tests/invalid/undef_inst.err_exp
diff -N tests/invalid/undef_inst.err_exp
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ tests/invalid/undef_inst.err_exp	22 Nov 2002 07:54:08 -0000
@@ -0,0 +1,6 @@
+undef_inst.m:  1: Warning: interface for module `undef_inst' does not export anything.
+undef_inst.m:004: In mode declaration for predicate `undef_inst:x'/1:
+undef_inst.m:004:   error: undefined inst `foo'/0.
+undef_inst.m:004: In mode declaration for predicate `undef_inst:x'/1:
+undef_inst.m:004:   error: undefined inst `bar'/0.
+For more information, try recompiling with `-E'.
Index: tests/invalid/undef_inst.m
===================================================================
RCS file: tests/invalid/undef_inst.m
diff -N tests/invalid/undef_inst.m
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ tests/invalid/undef_inst.m	22 Nov 2002 07:52:17 -0000
@@ -0,0 +1,6 @@
+:- module undef_inst.
+
+:- pred x(int).
+:- mode x(foo >> bar) is det.
+
+x(1).

-- 
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