diff: new test case tests/general/mode_inf.m

Fergus Henderson fjh at cs.mu.oz.au
Wed Jan 14 14:23:40 AEDT 1998


tests/general/Mmakefile:
tests/general/mode_inf.m:
tests/general/mode_inf.exp:
	Add another test of mode inference.

cvs diff: Diffing .
Index: Mmakefile
===================================================================
RCS file: /home/mercury1/repository/tests/general/Mmakefile,v
retrieving revision 1.2
diff -u -u -r1.2 Mmakefile
--- Mmakefile	1998/01/09 04:57:34	1.2
+++ Mmakefile	1998/01/14 03:10:08
@@ -43,7 +43,9 @@
 		liveness \
 		liveness2 \
 		mode_inf_bug \
+		mode_inf \
 		mu \
+		nondet_ite_2 \
 		parse_list \
 		petdr1 \
 		prune_switch \
@@ -53,13 +55,13 @@
 		string_test \
 		string_test_2 \
 		univ \
-		unreachable \
-		nondet_ite_2
+		unreachable 
 
 # space.m does not work, due to an unfixed bug in code generation.
 NOT_WORKING =	space
 
-# mode_inf_bug needs to be compiled with `--infer-all'.
+# mode_inf and mode_inf_bug need to be compiled with `--infer-all'.
+MCFLAGS-mode_inf = --infer-all
 MCFLAGS-mode_inf_bug = --infer-all
 
 # In grade `none' with options `-O1 --opt-space' on kryten
Index: mode_inf.exp
===================================================================
RCS file: mode_inf.exp
diff -N mode_inf.exp
--- /dev/null	Wed Jan 14 14:21:58 1998
+++ mode_inf.exp	Wed Jan 14 14:22:00 1998
@@ -0,0 +1,3 @@
+43
+44
+45
Index: mode_inf.m
===================================================================
RCS file: mode_inf.m
diff -N mode_inf.m
--- /dev/null	Wed Jan 14 14:21:58 1998
+++ mode_inf.m	Wed Jan 14 14:21:51 1998
@@ -0,0 +1,29 @@
+:- module mode_inf.
+:- interface.
+:- use_module(io).
+
+:- pred main(io__state::di, io__state::uo) is det.
+
+:- implementation.
+:- use_module((array, int, std_util)).
+
+main -->
+	{ solutions(lambda([X::out] is multi, do_some_stuff(X)), L) },
+	io__write_list(L, "\n", io__write), io__nl.
+
+do_some_stuff(X) :-
+	some_array_stuff(42, Y),
+	some_backtracking_stuff(Y, X, _).
+
+some_array_stuff(X, Y) :-
+	array__init(40, 80, A0),
+	array__set(A0, 37, X, A1),
+	array__lookup(A1, 37, Y).
+
+some_backtracking_stuff(X, Y, Z) :- Y is X + 1, p(Z).
+some_backtracking_stuff(X, Y, Z) :- Y is X + 2, p(Z).
+some_backtracking_stuff(X, Y, Z) :- Y is X + 3, p(Z).
+
+p(1).
+p(2).
+
-- 
Fergus Henderson <fjh at cs.mu.oz.au>   |  "I have always known that the pursuit
WWW: <http://www.cs.mu.oz.au/~fjh>   |  of excellence is a lethal habit"
PGP: finger fjh at 128.250.37.3         |     -- the last words of T. S. Garp.



More information about the developers mailing list