[m-rev.] diff: disable some non-applicable tests in non-C grades

Peter Wang novalazy at gmail.com
Mon Sep 17 17:22:01 AEST 2007


Estimated hours taken: 1
Branches: main

hard_coded/Mmakefile:
	Disable solver type tests in non-C grades.

	Disable C foreign interface tests in non-C grades.

	Disable C runtime option test in non-C grades.

valid/Mmakefile:
	Disable solver type tests in non-C grades.

	Disable C foreign interface tests in non-C grades.

	Delete stray `$' character.

hard_coded/foreign_import_module.m:
hard_coded/foreign_import_module_2.m:
valid/mert.m:
valid/solver_type_bug.m:
	Make these test cases work in Erlang

hard_coded/write_xml.m:
	Add Erlang foreign code (still fails for other reasons).


Index: hard_coded/Mmakefile
===================================================================
RCS file: /home/mercury/mercury1/repository/tests/hard_coded/Mmakefile,v
retrieving revision 1.330
diff -u -r1.330 Mmakefile
--- hard_coded/Mmakefile	20 Aug 2007 03:36:18 -0000	1.330
+++ hard_coded/Mmakefile	17 Sep 2007 06:45:04 -0000
@@ -8,8 +8,6 @@
 	abstract_eqv \
 	address_of_builtins \
 	agg \
-	any_call_hoist_bug \
-	any_free_unify \
 	array_test \
 	backquoted_qualified_ops \
 	bag_various \
@@ -159,9 +157,7 @@
 	pprint_test \
 	pprint_test2 \
 	pragma_c_code \
-	pragma_export \
 	pragma_foreign_export \
-	pragma_import \
 	pragma_inline \
 	pretty_printing \
 	prince_frameopt \
@@ -190,15 +186,10 @@
 	rtc_bug \
 	rtree_test \
 	rtti_strings \
-	runtime_opt \
 	seek_test \
 	setjmp_test \
 	shift_test \
 	solve_quadratic \
-	solver_build_call \
-	solver_construction_init_test \
-	solver_disj_inits \
-	solver_ite_inits \
 	space \
 	stable_sort \
 	stream_format \
@@ -305,6 +296,19 @@
 	target_mlobjs \
 	time_test
 
+# Solver types only work in C grades
+ifeq "$(filter il% java% erlang%,$(GRADE))" ""
+	SOLVER_PROGS = \
+		any_call_hoist_bug \
+		any_free_unify \
+		solver_build_call \
+		solver_construction_init_test \
+		solver_disj_inits \
+		solver_ite_inits
+else
+	SOLVER_PROGS =
+endif
+
 # Some tests only link in trailing grades.
 ifeq "$(filter tr%,$(GRADE))" ""
 	TRAILED_PROGS =
@@ -353,12 +357,17 @@
 # Fact tables currently work only in the C grades.
 # The foreign_type_assertion test is currently meaningful only in C grades.
 # The lookup_disj test case uses C foreign_proc code to print progress reports.
+# Tests of the C foreign language interface only work in C grades.
+# Runtime options are specific to the C backend.
 ifeq "$(filter il% java% erlang%,$(GRADE))" ""
 	C_ONLY_PROGS= \
 		factt \
 		factt_sort_test \
 		foreign_type_assertion \
-		lookup_disj
+		lookup_disj \
+		pragma_export \
+		pragma_import \
+		runtime_opt
 else
 	C_ONLY_PROGS=
 endif
@@ -573,8 +582,8 @@
 		$(BACKEND_PROGS) $(NONDET_C_PROGS) \
 		$(C_AND_GC_ONLY_PROGS) $(STATIC_LINK_PROGS) \
 		$(CHAR_REP_PROGS) $(C_ONLY_PROGS) \
-		$(DOTNET_PROGS) $(JAVA_PROGS) $(TRAILED_PROGS) \
-		$(MUTABLE_PROGS) $(TRACE_GOAL_ENV_PROGS)
+		$(DOTNET_PROGS) $(JAVA_PROGS) $(SOLVER_PROGS) \
+		$(TRAILED_PROGS) $(MUTABLE_PROGS) $(TRACE_GOAL_ENV_PROGS)
 endif
 
 #-----------------------------------------------------------------------------#
Index: hard_coded/foreign_import_module.m
===================================================================
RCS file: /home/mercury/mercury1/repository/tests/hard_coded/foreign_import_module.m,v
retrieving revision 1.5
diff -u -r1.5 foreign_import_module.m
--- hard_coded/foreign_import_module.m	16 Jul 2007 05:04:02 -0000	1.5
+++ hard_coded/foreign_import_module.m	17 Sep 2007 06:41:25 -0000
@@ -21,6 +21,8 @@
 
 :- pragma foreign_import_module(c, foreign_import_module_2).
 :- pragma foreign_import_module(il, foreign_import_module_2).
+% not actually necessary in Erlang
+% :- pragma foreign_import_module(erlang, foreign_import_module_2).
 
 :- pragma foreign_proc("C",
 	bar(X::in, Y::out),
@@ -43,6 +45,12 @@
 		throw new System.Exception(""Y1 != Y2"");
 	}
 ").
+:- pragma foreign_proc("Erlang",
+	bar(X::in, Y::out),
+	[may_call_mercury, promise_pure],
+"
+	Y = foreign_import_module_2:foo(X)
+").
 
 :- pred bar2(int::in, int::out) is det.
 :- pragma foreign_proc("C",
@@ -66,3 +74,9 @@
 		throw new System.Exception(""Y1 != Y2"");
 	}
 ").
+:- pragma foreign_proc("Erlang",
+	bar2(X::in, Y::out),
+	[may_call_mercury, promise_pure],
+"
+	Y = foreign_import_module_2:foo(X)
+").
Index: hard_coded/foreign_import_module_2.m
===================================================================
RCS file: /home/mercury/mercury1/repository/tests/hard_coded/foreign_import_module_2.m,v
retrieving revision 1.4
diff -u -r1.4 foreign_import_module_2.m
--- hard_coded/foreign_import_module_2.m	16 Jul 2007 05:04:02 -0000	1.4
+++ hard_coded/foreign_import_module_2.m	17 Sep 2007 06:39:59 -0000
@@ -10,6 +10,7 @@
 
 :- pragma foreign_export("IL", foo(in, out), "foo").
 :- pragma foreign_export("C", foo(in, out), "foo").
+:- pragma foreign_export("Erlang", foo(in, out), "foo").
 
 foo(X, X+1).
 
Index: hard_coded/write_xml.m
===================================================================
RCS file: /home/mercury/mercury1/repository/tests/hard_coded/write_xml.m,v
retrieving revision 1.7
diff -u -r1.7 write_xml.m
--- hard_coded/write_xml.m	30 Oct 2006 07:20:57 -0000	1.7
+++ hard_coded/write_xml.m	17 Sep 2007 06:48:08 -0000
@@ -44,6 +44,7 @@
 :- pred make_ftype(ftype::out) is det.
 
 :- pragma foreign_type("C", ftype, "int").
+:- pragma foreign_type("Erlang", ftype, "").
 
 :- pragma foreign_proc("C", make_ftype(F::out),
 	[will_not_call_mercury, thread_safe, promise_pure],
@@ -51,6 +52,12 @@
 	F = 1;
 ").
 
+:- pragma foreign_proc("Erlang", make_ftype(F::out),
+	[will_not_call_mercury, thread_safe, promise_pure],
+"
+	F = 1
+").
+
 :- pred make_pointer(c_pointer::out) is det.
 
 :- pragma foreign_proc("C", make_pointer(P::out),
@@ -59,6 +66,12 @@
 	P = (MR_Word) NULL;
 ").
 
+:- pragma foreign_proc("Erlang", make_pointer(P::out),
+	[will_not_call_mercury, thread_safe, promise_pure],
+"
+	P = null
+").
+
 :- pred p(int::in, int::in, mytype::in, int::out) is det.
 
 p(_, _, _, 1).
Index: valid/Mmakefile
===================================================================
RCS file: /home/mercury/mercury1/repository/tests/valid/Mmakefile,v
retrieving revision 1.193
diff -u -r1.193 Mmakefile
--- valid/Mmakefile	13 Aug 2007 03:02:01 -0000	1.193
+++ valid/Mmakefile	17 Sep 2007 06:54:28 -0000
@@ -123,7 +123,6 @@
 	intermod_nested_module \
 	intermod_nested_module_bug \
 	intermod_nested_uniq \
-	intermod_pragma_import \
 	intermod_quote \
 	intermod_record \
 	intermod_test \
@@ -191,10 +190,7 @@
 	simplify_bug2 \
 	size_prof_ho_bug \
 	soln_context \
-	solv \
 	solver_type_bug \
-	solver_type_bug_2 \
-	solver_type_mutable_bug \
 	some_switch \
 	spurious_purity_warning \
 	stack_alloc \
@@ -227,6 +223,14 @@
 	vn_float \
 	zero_arity
 
+C_INTERFACE_PROGS = \
+	intermod_pragma_import
+
+SOLVER_PROGS = \
+	solv \
+	solver_type_bug_2 \
+	solver_type_mutable_bug
+
 DEEP_PROF_CAPABLE_PROGS = \
 	impure_detism
 
@@ -310,7 +314,7 @@
 
 ifneq "$(filter java% il% erlang%,$(GRADE))$(findstring profdeep,$(GRADE))" ""
 	# We currently don't do any testing in grade java on this directory.
-	ifneq "$(findstring java,$(GRADE))$" ""
+	ifneq "$(findstring java,$(GRADE))" ""
 		PROGS3 =
 	else
 		PROGS3 = $(PROGS2)
@@ -320,7 +324,8 @@
 endif
 
 ifeq "$(filter hl% java% il% erlang%,$(GRADE))" ""
-	PROGS4 = $(PROGS3) $(DEEP_PROF_CAPABLE_PROGS) $(LLDS_PROGS)
+	PROGS4 = $(PROGS3) $(C_INTERFACE_PROGS) $(SOLVER_PROGS) \
+		$(DEEP_PROF_CAPABLE_PROGS) $(LLDS_PROGS)
 else
 	PROGS4 = $(PROGS3)
 endif
Index: valid/mert.m
===================================================================
RCS file: /home/mercury/mercury1/repository/tests/valid/mert.m,v
retrieving revision 1.2
diff -u -r1.2 mert.m
--- valid/mert.m	20 Dec 2006 05:08:06 -0000	1.2
+++ valid/mert.m	17 Sep 2007 06:10:20 -0000
@@ -41,10 +41,12 @@
 :- type c_candidate. % C-implemented, represents one sentence
 :- pragma foreign_type("C", c_candidate, "void *",
     [stable, can_pass_as_mercury_type]).
+:- pragma foreign_type("Erlang", c_candidate, "").
 
 :- type data. % C-implemented, represents the whole nbestlist
 :- pragma foreign_type("C", data, "void *",
     [stable, can_pass_as_mercury_type]).
+:- pragma foreign_type("Erlang", data, "").
 
 :- type feats == list(float). % score breakdown
 
@@ -61,6 +63,13 @@
   /* NFeats, Feats, NComps, Comps, C */
 ").
 
+:- pragma foreign_proc("Erlang",
+new_c_candidate(NFeats::in, Feats::in, NComps::in, Comps::in) = (C::uo),
+  [promise_pure, will_not_call_mercury, thread_safe], "
+  % NFeats, Feats, NComps, Comps, C
+  C = void
+").
+
 :- func nbestlist_to_data(scorednbestlist) = data.
   % construct data (using GC_malloc)
 nbestlist_to_data(NBL) = OutData :-
@@ -81,10 +90,17 @@
   [promise_pure, will_not_call_mercury, thread_safe], "
   /* NSents, CandsPerSent, TotNCands, AllCands */
 ").
+:- pragma foreign_proc("Erlang",
+new_c_data(NSents::in, CandsPerSent::in, TotNCands::in, AllCands::in) = (D::uo),
+  [promise_pure, will_not_call_mercury, thread_safe], "
+  % NSents, CandsPerSent, TotNCands, AllCands
+  D = void
+").
 
 :- type point. % C-implemented, represents the whole nbestlist
 :- pragma foreign_type("C", point, "void *",
     [stable, can_pass_as_mercury_type]).
+:- pragma foreign_type("Erlang", point, "").
 
 optimize(NBL, Rand, InW) = OutW :-
   Data = nbestlist_to_data(NBL),
@@ -112,6 +128,12 @@
   [promise_pure, will_not_call_mercury, thread_safe], "
   /* Data, BestSoFar, Min, Max, Iter */
 ").
+:- pragma foreign_proc("Erlang",
+optimize_random(Data::in, BestSoFar::in, Min::in, Max::in, Iter::in) = (Out::out),
+  [promise_pure, will_not_call_mercury, thread_safe], "
+  % Data, BestSoFar, Min, Max, Iter
+  Out = void
+").
 
 :- func optimize_koehn(data, point) = point.
   % destructively replace contents of point doing one iteration of optimization
@@ -121,6 +143,12 @@
   [promise_pure, will_not_call_mercury, thread_safe], "
   /* Data, In, Out */
 ").
+:- pragma foreign_proc("Erlang",
+optimize_koehn(Data::in, In::in) = (Out::out),
+  [promise_pure, will_not_call_mercury, thread_safe], "
+  % Data, In, Out
+  Out = void
+").
 
 :- func construct_point(list(float)) = point.
   % construct a new point, uses plain malloc!
@@ -133,6 +161,11 @@
   [promise_pure, will_not_call_mercury, thread_safe], "
   /* List, Point */
 ").
+:- pragma foreign_proc("Erlang",
+construct_point(List::in) = (Point::out),
+  [promise_pure, will_not_call_mercury, thread_safe], "
+  Point = List
+").
 
 :- pragma foreign_proc("C",
 deconstruct_point(Point::in) = (List::out),
@@ -140,6 +173,12 @@
   /* Point, List */
 ").
 
+:- pragma foreign_proc("Erlang",
+deconstruct_point(Point::in) = (List::out),
+  [promise_pure, will_not_call_mercury, thread_safe], "
+  List = Point
+").
+
 :- type bleucomps == list(int).
 
 :- type nbestlist == list(list(candidate)).
Index: valid/solver_type_bug.m
===================================================================
RCS file: /home/mercury/mercury1/repository/tests/valid/solver_type_bug.m,v
retrieving revision 1.1
diff -u -r1.1 solver_type_bug.m
--- valid/solver_type_bug.m	5 Dec 2003 04:18:32 -0000	1.1
+++ valid/solver_type_bug.m	17 Sep 2007 06:17:14 -0000
@@ -10,6 +10,7 @@
 :- pragma foreign_type("C", foo1, "int").
 :- pragma foreign_type("IL", foo1, "int32").
 :- pragma foreign_type("Java", foo1, "int").
+:- pragma foreign_type("Erlang", foo1, "").
 
 :- type foo2 ---> foo2(foo1).
 
@@ -32,3 +33,8 @@
 :- pred q2(foo2).
 :- mode q2(in(any)) is nondet.
 :- external(q2/1).
+
+:- pragma foreign_code("Erlang", "
+q1_1_p_0(_, _) -> void.
+q2_1_p_0(_, _) -> void.
+").

--------------------------------------------------------------------------
mercury-reviews mailing list
Post messages to:       mercury-reviews at csse.unimelb.edu.au
Administrative Queries: owner-mercury-reviews at csse.unimelb.edu.au
Subscriptions:          mercury-reviews-request at csse.unimelb.edu.au
--------------------------------------------------------------------------



More information about the reviews mailing list