[m-rev.] For review: fix broken solver type test cases

Ralph Becket rafe at cs.mu.OZ.AU
Tue Nov 8 15:47:57 AEDT 2005


Estimated hours taken: 1
Branches: main

tests/hard_coded/solver_build_call.m:
tests/invalid/any_passed_as_ground.m:
tests/invalid/any_to_ground_in_ite_cond.m:
tests/valid/solv.m:
	Fix some test cases that were broken by my recent change that made
	goals impure that occurred in negated contexts and contained inst any
	non-locals.

Index: tests/hard_coded/solver_build_call.m
===================================================================
RCS file: /home/mercury1/repository/tests/hard_coded/solver_build_call.m,v
retrieving revision 1.1
diff -u -r1.1 solver_build_call.m
--- tests/hard_coded/solver_build_call.m	26 Oct 2005 03:04:25 -0000	1.1
+++ tests/hard_coded/solver_build_call.m	8 Nov 2005 04:41:19 -0000
@@ -34,10 +34,9 @@
 %-----------------------------------------------------------------------------%
 
 main(!IO) :-
-    ( if
-        post_constraint(  B \/ -C),
-        post_constraint( -B \/  C),
-        solve([B, C], Solution)
+    promise_pure (
+      if
+        solve_problem(Solution)
       then
         io.print("solution found: ", !IO),
         io.print(Solution, !IO),
@@ -46,6 +45,13 @@
         io.print("no solution found\n", !IO)
     ).
 
+:- pred solve_problem(int::out) is semidet.
+
+solve_problem(Solution) :-
+    post_constraint( B \/ -C),
+    post_constraint(-B \/  C),
+    solve([B, C], Solution).
+
 :- solver type st
     where   representation is int,
             initialisation is init.
Index: tests/invalid/any_passed_as_ground.m
===================================================================
RCS file: /home/mercury1/repository/tests/invalid/any_passed_as_ground.m,v
retrieving revision 1.1
diff -u -r1.1 any_passed_as_ground.m
--- tests/invalid/any_passed_as_ground.m	13 Sep 2005 01:54:13 -0000	1.1
+++ tests/invalid/any_passed_as_ground.m	8 Nov 2005 03:57:29 -0000
@@ -33,7 +33,7 @@
 %
 main(!IO) :-
     p(Xs),
-    ( if member((X - _), Xs) then Y = X else Y = 0 ),
+    promise_pure ( if impure member((X - _), Xs) then Y = X else Y = 0 ),
     io.write_int(Y, !IO).
 
 :- pred i(st::oa) is det.
Index: tests/invalid/any_to_ground_in_ite_cond.m
===================================================================
RCS file: /home/mercury1/repository/tests/invalid/any_to_ground_in_ite_cond.m,v
retrieving revision 1.1
diff -u -r1.1 any_to_ground_in_ite_cond.m
--- tests/invalid/any_to_ground_in_ite_cond.m	13 Sep 2005 01:54:13 -0000	1.1
+++ tests/invalid/any_to_ground_in_ite_cond.m	8 Nov 2005 04:00:07 -0000
@@ -32,7 +32,8 @@
 %
 main(!IO) :-
     i(X),
-    ( if p(X) then
+    promise_pure (
+      if impure p(X) then
         io.write_string("aye\n", !IO)
       else
         io.write_string("nay\n", !IO)
Index: tests/valid/solv.m
===================================================================
RCS file: /home/mercury1/repository/tests/valid/solv.m,v
retrieving revision 1.2
diff -u -r1.2 solv.m
--- tests/valid/solv.m	10 Sep 2004 03:50:30 -0000	1.2
+++ tests/valid/solv.m	8 Nov 2005 04:27:33 -0000
@@ -58,7 +58,15 @@
 		any            is ground.
 
 print_labeling(Vars) -->
-	unsorted_aggregate(labeling(Vars), print_solution).
+	{ Labeling0 = (
+		impure pred(Labels::out) is nondet :-
+			labeling(Vars, Labels)
+	) },
+	{ Labeling = (
+		pred(Labels::out) is nondet :-
+			promise_pure ( impure Labeling0(Labels) )
+	) },
+	unsorted_aggregate(Labeling, print_solution).
 
 :- pred print_solution(list(fd_var), io__state, io__state).
 :- mode print_solution(in, di, uo) is det.
--------------------------------------------------------------------------
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