[m-rev.] diff: fix simple erlang test failures

Peter Wang wangp at students.csse.unimelb.edu.au
Wed Jun 6 11:49:50 AEST 2007


Estimated hours taken: 1.5
Branches: main

library/io.m:
	Implement some more I/O primitives for Erlang.

tests/debugger/Mmakefile:
tests/debugger/declarative/Mmakefile:
tests/hard_coded/Mmakefile:
tests/invalid/Mmakefile:
tests/par_conj/Mmakefile:
tests/recompilation/Mmakefile:
tests/valid/Mmakefile:
	Disable test cases which don't apply to the Erlang backend for
	whatever reason.

tests/hard_coded/constraint_order.m:
tests/hard_coded/copy_pred.m:
tests/hard_coded/copy_pred_2.m:
tests/hard_coded/export_test.m:
tests/hard_coded/external_unification_pred.m:
tests/hard_coded/foreign_type3.m:
tests/hard_coded/ho_solns.m:
tests/hard_coded/ho_univ_to_type.m:
tests/hard_coded/intermod_multimode.m:
tests/hard_coded/intermod_poly_mode_2.m:
tests/hard_coded/lookup_disj.m:
tests/hard_coded/multimode.m:
tests/hard_coded/no_inline.m:
tests/hard_coded/pragma_foreign_export.m:
tests/hard_coded/redoip_clobber.m:
tests/hard_coded/rnd.m:
tests/hard_coded/sub-modules/sm_exp_bug.m:
tests/hard_coded/typeclasses/impure_methods.m:
tests/par_conj/dep_par_10.m:
tests/valid/flatten_conj_bug.m:
	Fix test cases which were failing with the Erlang backend for simple reasons,
	mostly missing foreign procs or foreign types.

tests/general/string_format_test_2.exp5:
tests/general/string_format_test_3.exp5:
tests/hard_coded/exceptions/test_uncaught_exception.exp5:
tests/hard_coded/no_fully_strict.exp5:
	Add expected outputs with stack dumps for Erlang.

Index: library/io.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/library/io.m,v
retrieving revision 1.389
diff -u -r1.389 io.m
--- library/io.m	5 Jun 2007 08:20:46 -0000	1.389
+++ library/io.m	6 Jun 2007 01:40:34 -0000
@@ -7490,6 +7490,14 @@
 ").

 :- pragma foreign_proc("Erlang",
+    io.write_int_2(Stream::in, Val::in, _IO0::di, _IO::uo),
+    [may_call_mercury, promise_pure, tabled_for_io, thread_safe, terminates],
+"
+    {'ML_stream', _Id, IoDevice} = Stream,
+    io:write(IoDevice, Val)
+").
+
+:- pragma foreign_proc("Erlang",
     io.write_string_2(Stream::in, Message::in, _IO0::di, _IO::uo),
     [will_not_call_mercury, promise_pure, thread_safe, tabled_for_io,
         terminates],
@@ -7498,6 +7506,24 @@
     io:put_chars(IoDevice, Message)
 ").

+:- pragma foreign_proc("Erlang",
+    io.flush_output_2(Stream::in, _IO0::di, _IO::uo),
+    [will_not_call_mercury, promise_pure, thread_safe, tabled_for_io,
+        terminates],
+"
+    {'ML_stream', _Id, IoDevice} = Stream,
+    file:sync(IoDevice)
+").
+
+:- pragma foreign_proc("Erlang",
+    io.flush_binary_output(Stream::in, _IO0::di, _IO::uo),
+    [will_not_call_mercury, promise_pure, thread_safe, tabled_for_io,
+        terminates],
+"
+    {'ML_stream', _Id, IoDevice} = Stream,
+    file:sync(IoDevice)
+").
+
 io.write_float_2(Stream, Float, !IO) :-
     io.write_string_2(Stream, string.float_to_string(Float), !IO).

Index: tests/debugger/Mmakefile
===================================================================
RCS file: /home/mercury/mercury1/repository/tests/debugger/Mmakefile,v
retrieving revision 1.135
diff -u -r1.135 Mmakefile
--- tests/debugger/Mmakefile	31 May 2007 02:01:21 -0000	1.135
+++ tests/debugger/Mmakefile	6 Jun 2007 01:40:34 -0000
@@ -175,6 +175,7 @@
 			$(TERM_SIZE_PROGS) $(MMOS_PROGS)

 # Debugging doesn't yet don't work in MLDS grades (hl*, il*, and java),
+# or the Erlang grade,
 # and the retry command doesn't and will not work in deep profiling
 # grades (profdeep).
 # Also base grades `jump' and `fast' cannot be used with
@@ -190,7 +191,7 @@
     DEBUGGER_PROGS=$(ALL_NONRETRY_PROGS) $(ALL_RETRY_PROGS)
 endif

-ifneq "$(filter hl% java% il%,$(GRADE))" ""
+ifneq "$(filter hl% java% il% erlang%,$(GRADE))" ""
     PROGS=
 else
     ifneq "$(findstring asm_,$(GRADE))" ""
Index: tests/debugger/declarative/Mmakefile
===================================================================
RCS file: /home/mercury/mercury1/repository/tests/debugger/declarative/Mmakefile,v
retrieving revision 1.98
diff -u -r1.98 Mmakefile
--- tests/debugger/declarative/Mmakefile	18 Jan 2007 07:46:00 -0000	1.98
+++ tests/debugger/declarative/Mmakefile	6 Jun 2007 01:40:34 -0000
@@ -135,13 +135,13 @@
 endif

 # Debugging does not work in MLDS (hl*, il*, and java*) grades
-# or deep profiling (profdeep) grades.
+# or Erlang grades or deep profiling (profdeep) grades.
 # Base grades `jump' and `fast' cannot be used with
 # stack layouts (which are required for tracing).
 # Currently, declarative debugging does not work in `rt' grades.
 # Also, declarative debugging only works in `.gc' grades.

-ifeq "$(filter hl% il% java%,$(GRADE))$(findstring profdeep,$(GRADE))" ""
+ifeq "$(filter hl% il% java% erlang%,$(GRADE))$(findstring
profdeep,$(GRADE))" ""
     ifneq "$(findstring .gc,$(GRADE))" ""
         ifneq "$(findstring rt,$(GRADE))" ""
 	    PROGS=
Index: tests/hard_coded/Mmakefile
===================================================================
RCS file: /home/mercury/mercury1/repository/tests/hard_coded/Mmakefile,v
retrieving revision 1.318
diff -u -r1.318 Mmakefile
--- tests/hard_coded/Mmakefile	1 Jun 2007 12:54:14 -0000	1.318
+++ tests/hard_coded/Mmakefile	6 Jun 2007 01:40:35 -0000
@@ -323,7 +323,7 @@
 # Mutables work properly only in C grades.
 # Trace goal with runtime conditions work properly only in C grades.
 # The lookup_disj test case uses C foreign_proc code to print progress reports.
-ifeq "$(filter il% java%,$(GRADE))" ""
+ifeq "$(filter il% java% erlang%,$(GRADE))" ""
 	C_ONLY_PROGS= \
 		factt \
 		factt_sort_test \
@@ -465,7 +465,7 @@
 # be replaced by a test that exercises functionality enabled by type tables.
 # However, this must wait for the implementation of that functionality.

-ifeq "$(filter hl% il% java%,$(GRADE))" ""
+ifeq "$(filter hl% il% java% erlang%,$(GRADE))" ""
 	ifeq "$(findstring profdeep,$(GRADE))" ""
 		BACKEND_PROGS_2 = \
 			factt_non
@@ -487,11 +487,11 @@
 # The MLDS back-end doesn't support nondet C in trailing grades,
 # or in no-GC grades (except with --no-reclaim-heap-on-failure).
 # We also don't support nondet C in deep profiling grades.
-# These tests are also not supported in IL and Java grades,
+# These tests are also not supported in IL, Java and Erlang grades,
 # since those back-ends don't support the C interface at all.
 # (XXX perhaps we should add analogous tests of the nondet IL, C#, MC++,
 # and [eventually] Java interfaces?)
-ifneq "$(filter il% java%,$(GRADE))" ""
+ifneq "$(filter il% java% erlang%,$(GRADE))" ""
 	NONDET_C_PROGS =
 else
   ifeq "$(findstring hl,$(GRADE))$(findstring .tr,$(GRADE))" "hl.tr"
@@ -532,7 +532,7 @@
   ifneq "$(findstring solaris,$(FULLARCH))" "solaris"
 	# The `parse' test also links with the debug libraries,
 	# so it only works in LLDS grades.
-	ifeq "$(filter hl% java% il%,$(GRADE))" ""
+	ifeq "$(filter hl% java% il% erlang%,$(GRADE))" ""
 		STATIC_LINK_PROGS = parse
 	endif
   endif
Index: tests/hard_coded/constraint_order.m
===================================================================
RCS file: /home/mercury/mercury1/repository/tests/hard_coded/constraint_order.m,v
retrieving revision 1.3
diff -u -r1.3 constraint_order.m
--- tests/hard_coded/constraint_order.m	28 Nov 2002 18:47:31 -0000	1.3
+++ tests/hard_coded/constraint_order.m	6 Jun 2007 01:40:35 -0000
@@ -42,3 +42,8 @@
 :- pragma c_code(puts(Str::in), "puts(Str);").
 :- pragma foreign_proc("C#", puts(Str::in), [],
 		"System.Console.WriteLine(Str);").
+:- pragma foreign_proc("Erlang", puts(Str::in), [],
+"
+    io:put_chars(Str),
+    io:nl()
+").
Index: tests/hard_coded/copy_pred.m
===================================================================
RCS file: /home/mercury/mercury1/repository/tests/hard_coded/copy_pred.m,v
retrieving revision 1.4
diff -u -r1.4 copy_pred.m
--- tests/hard_coded/copy_pred.m	29 Mar 2006 08:07:59 -0000	1.4
+++ tests/hard_coded/copy_pred.m	6 Jun 2007 01:40:35 -0000
@@ -29,6 +29,9 @@
 	:- pragma foreign_proc("Java",
 		inst_cast(X::in, Y::out(pred(in, out) is det)),
 		[will_not_call_mercury, thread_safe, promise_pure], "Y = X;").
+	:- pragma foreign_proc("Erlang",
+		inst_cast(X::in, Y::out(pred(in, out) is det)),
+		[will_not_call_mercury, thread_safe, promise_pure], "Y = X").

         :- pred foo(int, int, string, string) is det.
         :- mode foo(in, in, in, out) is det.
Index: tests/hard_coded/copy_pred_2.m
===================================================================
RCS file: /home/mercury/mercury1/repository/tests/hard_coded/copy_pred_2.m,v
retrieving revision 1.3
diff -u -r1.3 copy_pred_2.m
--- tests/hard_coded/copy_pred_2.m	22 Mar 2006 02:56:28 -0000	1.3
+++ tests/hard_coded/copy_pred_2.m	6 Jun 2007 01:40:35 -0000
@@ -34,6 +34,9 @@
 :- pragma foreign_proc("C#",
 	inst_cast(X::in, Y::out(pred(in, out) is det)),
 	[will_not_call_mercury, thread_safe, promise_pure], "Y = X;").
+:- pragma foreign_proc("Erlang",
+	inst_cast(X::in, Y::out(pred(in, out) is det)),
+	[will_not_call_mercury, thread_safe, promise_pure], "Y = X").

 :- pred foo(T, T, string, string).
 :- mode foo(in, in, in, out) is det.
Index: tests/hard_coded/export_test.m
===================================================================
RCS file: /home/mercury/mercury1/repository/tests/hard_coded/export_test.m,v
retrieving revision 1.3
diff -u -r1.3 export_test.m
--- tests/hard_coded/export_test.m	28 Nov 2002 16:33:44 -0000	1.3
+++ tests/hard_coded/export_test.m	6 Jun 2007 01:40:35 -0000
@@ -33,3 +33,7 @@
 		[may_call_mercury, promise_pure], "
 	export_test.mercury_code.foo(X, ref Y);
 ").
+:- pragma foreign_proc("Erlang", bar(X::in, Y::out),
+		[may_call_mercury, promise_pure], "
+	{Y} = foo(X)
+").
Index: tests/hard_coded/external_unification_pred.m
===================================================================
RCS file: /home/mercury/mercury1/repository/tests/hard_coded/external_unification_pred.m,v
retrieving revision 1.1
diff -u -r1.1 external_unification_pred.m
--- tests/hard_coded/external_unification_pred.m	3 Dec 2003 16:12:10 -0000	1.1
+++ tests/hard_coded/external_unification_pred.m	6 Jun 2007 01:40:35 -0000
@@ -22,6 +22,7 @@
     :- pragma foreign_type(c, ft, "int") where equality is unify_ft.
     :- pragma foreign_type(il, ft, "valuetype [mscorlib]System.Int32")
 		    where equality is unify_ft.
+    :- pragma foreign_type(erlang, ft, "") where equality is unify_ft.

     :- pred unify_ft(ft::in, ft::in) is semidet.

@@ -33,6 +34,10 @@
     "
 	    SUCCESS_INDICATOR = (X == Y);
     ").
+    :- pragma foreign_proc("Erlang", unify_ft(X::in, Y::in), [promise_pure],
+    "
+	    SUCCESS_INDICATOR = (X =:= Y)
+    ").

     :- pragma foreign_proc("C", create_ft(X::in) = (Y::out), [promise_pure],
     "
@@ -42,6 +47,10 @@
     "
 	    Y = X;
     ").
+    :- pragma foreign_proc("Erlang", create_ft(X::in) = (Y::out),
[promise_pure],
+    "
+	    Y = X
+    ").
     :- end_module external_unification_pred.sub.

 :- import_module external_unification_pred.sub.
Index: tests/hard_coded/foreign_type3.m
===================================================================
RCS file: /home/mercury/mercury1/repository/tests/hard_coded/foreign_type3.m,v
retrieving revision 1.2
diff -u -r1.2 foreign_type3.m
--- tests/hard_coded/foreign_type3.m	28 Nov 2002 16:33:44 -0000	1.2
+++ tests/hard_coded/foreign_type3.m	6 Jun 2007 01:40:35 -0000
@@ -47,15 +47,18 @@
 :- pragma foreign_type(c, dir, "dirs").
 :- pragma foreign_type(il, dir,
 		"valuetype [foreign_type3__csharp_code]dirs").
+:- pragma foreign_type(erlang, dir, "").

 :- type coord.
 :- pragma foreign_type(c, coord, "coord").
 :- pragma foreign_type(il, coord,
 		"valuetype [foreign_type3__csharp_code]coord").
+:- pragma foreign_type(erlang, coord, "").

 :- type double.
 :- pragma foreign_type(c, double, "double").
 :- pragma foreign_type(il, double, "valuetype [mscorlib]System.Double").
+:- pragma foreign_type(erlang, double, "").

 :- func north = dir.
 :- pragma foreign_proc(c, north = (E::out),
@@ -66,6 +69,10 @@
 		[will_not_call_mercury, promise_pure], "
 	E = dirs.north;
 ").
+:- pragma foreign_proc("Erlang", north = (E::out),
+		[will_not_call_mercury, promise_pure], "
+	E = north
+").

 :- func new(int, int) = coord.
 :- pragma foreign_proc(c, new(X::in, Y::in) = (C::out),
@@ -78,6 +85,10 @@
 	C.x = X;
 	C.y = Y;
 ").
+:- pragma foreign_proc("Erlang", new(X::in, Y::in) = (C::out),
+		[will_not_call_mercury, promise_pure], "
+	C = {X, Y}
+").

 :- func pi = double.
 :- pragma foreign_proc(c, pi = (Pi::out),
@@ -88,3 +99,7 @@
 		[will_not_call_mercury, promise_pure], "
 	Pi = 3.14;
 ").
+:- pragma foreign_proc("Erlang", pi = (Pi::out),
+		[will_not_call_mercury, promise_pure], "
+	Pi = 3.14
+").
Index: tests/hard_coded/ho_solns.m
===================================================================
RCS file: /home/mercury/mercury1/repository/tests/hard_coded/ho_solns.m,v
retrieving revision 1.7
diff -u -r1.7 ho_solns.m
--- tests/hard_coded/ho_solns.m	10 Jul 2006 04:40:53 -0000	1.7
+++ tests/hard_coded/ho_solns.m	6 Jun 2007 01:40:35 -0000
@@ -48,6 +48,11 @@
 	L = L0;
 }
 ").
+:- pragma foreign_proc("Erlang",
+	convert_list(L0 :: in, L :: out(list_skel(mypred))),
+	[promise_pure], "
+	L = L0
+").

 :- pred use_list(list(mypred), io__state, io__state).
 :- mode use_list(in(list_skel(mypred)), di, uo) is det.
Index: tests/hard_coded/ho_univ_to_type.m
===================================================================
RCS file: /home/mercury/mercury1/repository/tests/hard_coded/ho_univ_to_type.m,v
retrieving revision 1.6
diff -u -r1.6 ho_univ_to_type.m
--- tests/hard_coded/ho_univ_to_type.m	10 Jul 2006 04:40:53 -0000	1.6
+++ tests/hard_coded/ho_univ_to_type.m	6 Jun 2007 01:40:35 -0000
@@ -66,5 +66,10 @@
 	Pred2 = Pred1;
 }
 ").
+:- pragma foreign_proc("Erlang",
+	convert_inst(Pred1::in, Pred2::out(mypred)),
+	[will_not_call_mercury, promise_pure], "
+	Pred2 = Pred1
+").


Index: tests/hard_coded/intermod_multimode.m
===================================================================
RCS file: /home/mercury/mercury1/repository/tests/hard_coded/intermod_multimode.m,v
retrieving revision 1.5
diff -u -r1.5 intermod_multimode.m
--- tests/hard_coded/intermod_multimode.m	10 Jul 2006 04:40:53 -0000	1.5
+++ tests/hard_coded/intermod_multimode.m	6 Jun 2007 01:40:35 -0000
@@ -91,6 +91,11 @@
 	puts(S)
 ").
 :- pragma foreign_proc("C#", puts(S::in), [], "System.Console.WriteLine(S);").
+:- pragma foreign_proc("Erlang", puts(S::in), [],
+"
+    io:put_chars(S),
+    io:nl()
+").

 :- pragma promise_pure(get_determinism/2).
 :- pragma inline(get_determinism/2).
Index: tests/hard_coded/intermod_poly_mode_2.m
===================================================================
RCS file: /home/mercury/mercury1/repository/tests/hard_coded/intermod_poly_mode_2.m,v
retrieving revision 1.1
diff -u -r1.1 intermod_poly_mode_2.m
--- tests/hard_coded/intermod_poly_mode_2.m	3 Nov 2005 07:03:16 -0000	1.1
+++ tests/hard_coded/intermod_poly_mode_2.m	6 Jun 2007 01:40:35 -0000
@@ -12,3 +12,9 @@
 "
 	R = X;
 ").
+:- pragma foreign_proc("Erlang",
+	new(X::in(I)) = (R::out(I)),
+	[promise_pure, will_not_call_mercury],
+"
+	R = X
+").
Index: tests/hard_coded/lookup_disj.m
===================================================================
RCS file: /home/mercury/mercury1/repository/tests/hard_coded/lookup_disj.m,v
retrieving revision 1.1
diff -u -r1.1 lookup_disj.m
--- tests/hard_coded/lookup_disj.m	11 Dec 2006 04:10:46 -0000	1.1
+++ tests/hard_coded/lookup_disj.m	6 Jun 2007 01:40:35 -0000
@@ -58,6 +58,14 @@
     Int = Int0 + 10;
 ").

+:- pragma foreign_proc("Erlang",
+    peek_at_solution(Int0::in, Int::out),
+    [will_not_call_mercury, promise_pure, thread_safe],
+"
+    io:format(""peek ~B~n"", [Int0]),
+    Int = Int0 + 10
+").
+
 :- pred write_solution(soln::in, io::di, io::uo) is det.

 write_solution(Soln, !IO) :-
Index: tests/hard_coded/multimode.m
===================================================================
RCS file: /home/mercury/mercury1/repository/tests/hard_coded/multimode.m,v
retrieving revision 1.4
diff -u -r1.4 multimode.m
--- tests/hard_coded/multimode.m	10 Jul 2006 04:40:54 -0000	1.4
+++ tests/hard_coded/multimode.m	6 Jun 2007 01:40:35 -0000
@@ -94,3 +94,10 @@
 ").
 :- pragma foreign_proc("C#", puts(S::in),
 		[promise_pure], "System.Console.WriteLine(S);").
+:- pragma foreign_proc("Erlang",
+	puts(S::in),
+	[will_not_call_mercury],
+"
+	io:put_chars(S),
+	io:nl()
+").
Index: tests/hard_coded/no_inline.m
===================================================================
RCS file: /home/mercury/mercury1/repository/tests/hard_coded/no_inline.m,v
retrieving revision 1.5
diff -u -r1.5 no_inline.m
--- tests/hard_coded/no_inline.m	28 Nov 2002 16:33:44 -0000	1.5
+++ tests/hard_coded/no_inline.m	6 Jun 2007 01:40:35 -0000
@@ -34,3 +34,12 @@
 ").
 :- pragma foreign_code("C#", "static int counter = 0;").
 :- pragma foreign_proc("C#", bar(Value::out), [], "Value = counter++;").
+:- pragma foreign_proc("Erlang", bar(Value::out), [], "
+    case get(counter) of
+	undefined ->
+	    Value = 0;
+	C ->
+	    Value = C
+    end,
+    put(counter, Value + 1)
+").
Index: tests/hard_coded/pragma_foreign_export.m
===================================================================
RCS file: /home/mercury/mercury1/repository/tests/hard_coded/pragma_foreign_export.m,v
retrieving revision 1.1
diff -u -r1.1 pragma_foreign_export.m
--- tests/hard_coded/pragma_foreign_export.m	19 Jul 2006 15:19:08 -0000	1.1
+++ tests/hard_coded/pragma_foreign_export.m	6 Jun 2007 01:40:35 -0000
@@ -16,6 +16,8 @@
 :- pred hello_world(io::di, io::uo) is det.
 :- pragma foreign_export("C", hello_world(di, uo),
 	"exported_hello_world").
+:- pragma foreign_export("Erlang", hello_world(di, uo),
+	"exported_hello_world").

 hello_world(!IO) :-
 	io.write_string("Hello World!\n", !IO).
@@ -27,3 +29,10 @@
 	exported_hello_world();
 	IO = IO0;
 ").
+
+:- pragma foreign_proc("Erlang",
+	call_foreign(_IO0::di, _IO::uo),
+	[promise_pure, may_call_mercury],
+"
+	exported_hello_world()
+").
Index: tests/hard_coded/redoip_clobber.m
===================================================================
RCS file: /home/mercury/mercury1/repository/tests/hard_coded/redoip_clobber.m,v
retrieving revision 1.4
diff -u -r1.4 redoip_clobber.m
--- tests/hard_coded/redoip_clobber.m	28 Nov 2002 16:33:45 -0000	1.4
+++ tests/hard_coded/redoip_clobber.m	6 Jun 2007 01:40:35 -0000
@@ -79,6 +79,11 @@

 	SUCCESS_INDICATOR = MR_FALSE;
 ").
+:- pragma foreign_proc("Erlang", use(_X::in),
+	[will_not_call_mercury, promise_pure],
+"
+	SUCCESS_INDICATOR = false
+").

 main -->
 	( { foo(X), use(X) } ->
Index: tests/hard_coded/rnd.m
===================================================================
RCS file: /home/mercury/mercury1/repository/tests/hard_coded/rnd.m,v
retrieving revision 1.3
diff -u -r1.3 rnd.m
--- tests/hard_coded/rnd.m	10 Jul 2006 04:40:54 -0000	1.3
+++ tests/hard_coded/rnd.m	6 Jun 2007 01:40:35 -0000
@@ -249,6 +249,8 @@
 ").
 :- pragma foreign_proc("C#", rfloat(I::in) = (F::out),
 		[promise_pure], "F = I;").
+:- pragma foreign_proc("Erlang", rfloat(I::in) = (F::out),
+		[promise_pure], "F = float(I)").

 :- func rint(float) = int.
 :- pragma foreign_proc("C",
@@ -259,6 +261,8 @@
 ").
 :- pragma foreign_proc("C#", rint(F::in) = (I::out),
 		[promise_pure], "I = (int) F;").
+:- pragma foreign_proc("Erlang", rint(F::in) = (I::out),
+		[promise_pure], "I = trunc(F)").

 :- pred for(int, int, pred(int, T, T), T, T).
 :- mode for(in, in, pred(in, in, out) is det, in, out) is det.
Index: tests/hard_coded/sub-modules/sm_exp_bug.m
===================================================================
RCS file: /home/mercury/mercury1/repository/tests/hard_coded/sub-modules/sm_exp_bug.m,v
retrieving revision 1.1
diff -u -r1.1 sm_exp_bug.m
--- tests/hard_coded/sub-modules/sm_exp_bug.m	4 Mar 2007 23:38:09 -0000	1.1
+++ tests/hard_coded/sub-modules/sm_exp_bug.m	6 Jun 2007 01:40:35 -0000
@@ -28,7 +28,15 @@
 	IO = IO0;
 ").

+:- pragma foreign_proc("Erlang",
+	call_foreign(_IO0::di, _IO::uo),
+	[may_call_mercury, promise_pure],
+"
+	'WRITE_HELLO'()
+").
+
 :- pragma foreign_export("C", write_hello(di, uo), "WRITE_HELLO").
+:- pragma foreign_export("Erlang", write_hello(di, uo), "WRITE_HELLO").
 :- pred write_hello(io::di, io::uo) is det.
 write_hello(!IO) :-
 	io.write_string("Hello World!\n", !IO).
Index: tests/hard_coded/typeclasses/impure_methods.m
===================================================================
RCS file: /home/mercury/mercury1/repository/tests/hard_coded/typeclasses/impure_methods.m,v
retrieving revision 1.5
diff -u -r1.5 impure_methods.m
--- tests/hard_coded/typeclasses/impure_methods.m	10 Jul 2006 04:40:56 -0000	1.5
+++ tests/hard_coded/typeclasses/impure_methods.m	6 Jun 2007 01:40:35 -0000
@@ -82,6 +82,23 @@
 :- pragma foreign_proc("Java", foo_m2(_F::in, Val::out),
 		[promise_semipure], "Val = foo_counter;").

+:- pragma foreign_proc("Erlang",
+	foo_m1(_F::in),
+	[will_not_call_mercury],
+"
+    put(foo_counter,
+	case get(foo_counter) of
+	    undefined -> 1;
+	    N -> N + 1
+	end)
+").
+:- pragma foreign_proc("Erlang",
+	foo_m2(_F::in, Val::out),
+	[will_not_call_mercury, promise_semipure],
+"
+	Val = get(foo_counter)
+").
+
 goo_m1(_).
 goo_m2(_, 42).

Index: tests/invalid/Mmakefile
===================================================================
RCS file: /home/mercury/mercury1/repository/tests/invalid/Mmakefile,v
retrieving revision 1.216
diff -u -r1.216 Mmakefile
--- tests/invalid/Mmakefile	21 May 2007 04:23:25 -0000	1.216
+++ tests/invalid/Mmakefile	6 Jun 2007 01:40:35 -0000
@@ -274,14 +274,14 @@

 # These tests test things which only work for back-ends which support
 # the C interface.
-ifneq "$(filter java% il%,$(GRADE))" ""
+ifneq "$(filter java% il% erlang%,$(GRADE))" ""
 	C_INTERFACE_PROGS=
 else
 	C_INTERFACE_PROGS=$(C_INTERFACE_MODULES)
 endif

 # The java and il grades compile with num_tag_bits = 0.
-ifneq "$(filter java% il%,$(GRADE))" ""
+ifneq "$(filter java% il% erlang%,$(GRADE))" ""
 	RESERVE_TAG_PROGS =
 else
 	RESERVE_TAG_PROGS = $(RESERVE_TAG_MODULES)
Index: tests/par_conj/Mmakefile
===================================================================
RCS file: /home/mercury/mercury1/repository/tests/par_conj/Mmakefile,v
retrieving revision 1.14
diff -u -r1.14 Mmakefile
--- tests/par_conj/Mmakefile	1 May 2007 01:11:43 -0000	1.14
+++ tests/par_conj/Mmakefile	6 Jun 2007 01:40:35 -0000
@@ -55,13 +55,13 @@
 	threads_hang

 # These tests require debugging, which hasn't been implemented for
-# the MLDS backend.
+# the MLDS backend or Erlang backend.
 #
 LLDS_PROGS = \
 	par_ddeath \
 	par_ddeath_2

-ifeq "$(filter hl% java% il%,$(GRADE))" ""
+ifeq "$(filter hl% java% il% erlang%,$(GRADE))" ""
 	PROGS0 = $(LLDS_PROGS)
 else
 	PROGS0 =
@@ -127,7 +127,7 @@

 # Exercise multiple Mercury engines in lowlevel grades.
 ENGINES :=
-ifeq "$(filter hl% java% il%,$(GRADE))" ""
+ifeq "$(filter hl% java% il% erlang%,$(GRADE))" ""
 	ENGINES := MERCURY_OPTIONS=-P2
 endif

@@ -135,7 +135,7 @@
 	{ [ -f $*.inp ] && cat $*.inp; } | $(ENGINES) ./$< > $@ 2>&1 || \
 		{ grep . $@ /dev/null; exit 1; }

-ifeq "$(filter hl% java% il%,$(GRADE))" ""
+ifeq "$(filter hl% java% il% erlang%,$(GRADE))" ""

 # Run threads_hang with multiple OS threads in lowlevel parallel grades.
 # Repeat the test a few times in increase the chances of getting a deadlock.
Index: tests/par_conj/dep_par_10.m
===================================================================
RCS file: /home/mercury/mercury1/repository/tests/par_conj/dep_par_10.m,v
retrieving revision 1.1
diff -u -r1.1 dep_par_10.m
--- tests/par_conj/dep_par_10.m	28 Jun 2006 04:46:21 -0000	1.1
+++ tests/par_conj/dep_par_10.m	6 Jun 2007 01:40:35 -0000
@@ -25,3 +25,9 @@
 "
     Y = X+1;
 ").
+:- pragma foreign_proc("Erlang",
+    fp(X::in) = (Y::out),
+    [will_not_call_mercury, promise_pure, thread_safe],
+"
+    Y = X+1
+").
Index: tests/recompilation/Mmakefile
===================================================================
RCS file: /home/mercury/mercury1/repository/tests/recompilation/Mmakefile,v
retrieving revision 1.13
diff -u -r1.13 Mmakefile
--- tests/recompilation/Mmakefile	25 Oct 2003 21:09:24 -0000	1.13
+++ tests/recompilation/Mmakefile	6 Jun 2007 01:40:35 -0000
@@ -42,9 +42,10 @@
 	type_qual_re \
 	with_type_re

-# We currently don't do any testing in java or il grades in this directory
-# because smart compilation doesn't support intermodule-optimization yet
-ifneq "$(filter java% il%,$(GRADE))" ""
+# We currently don't do any testing in java, il or erlang grades in this
+# directory because smart compilation doesn't support intermodule-optimization
+# yet
+ifneq "$(filter java% il% erlang%,$(GRADE))" ""
 	PROGS=
 else
 	PROGS= $(TESTS_SHOULD_SUCCEED) $(NO_PARALLEL_MAKE_TESTS) \
Index: tests/valid/Mmakefile
===================================================================
RCS file: /home/mercury/mercury1/repository/tests/valid/Mmakefile,v
retrieving revision 1.188
diff -u -r1.188 Mmakefile
--- tests/valid/Mmakefile	30 May 2007 23:44:17 -0000	1.188
+++ tests/valid/Mmakefile	6 Jun 2007 01:40:35 -0000
@@ -306,7 +306,7 @@
 	PROGS2=$(PROGS1) $(TRAIL_PROGS)
 endif

-ifneq "$(filter java% il%,$(GRADE))$(findstring profdeep,$(GRADE))" ""
+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))$" ""
 		PROGS3 =
@@ -317,7 +317,7 @@
 	PROGS3 = $(PROGS2) $(TABLE_PROGS)
 endif

-ifeq "$(filter hl% java% il%,$(GRADE))" ""
+ifeq "$(filter hl% java% il% erlang%,$(GRADE))" ""
 	PROGS4 = $(PROGS3) $(DEEP_PROF_CAPABLE_PROGS) $(LLDS_PROGS)
 else
 	PROGS4 = $(PROGS3)
@@ -329,7 +329,7 @@
 	PROGS5 = $(PROGS4) $(PAR_CONJ_PROGS)
 endif

-ifeq "$(filter java% il%,$(GRADE))" ""
+ifeq "$(filter java% il% erlang%,$(GRADE))" ""
 	OBJ_PROGS = $(PROGS5) $(RESERVE_TAG_PROGS)
 else
 	OBJ_PROGS = $(PROGS5)
@@ -357,9 +357,15 @@
 	TARGET_OBJ_EXT=dll
 	TARGET_OBJ_SUBDIR=$(DLLS_SUBDIR)
 else
+ifeq ($(findstring erlang,$(GRADE)),erlang)
+	TARGET_OBJ_EXT=beam
+	# Erlang backend currently requires `mmc --make'.
+	TARGET_OBJ_SUBDIR=
+else
 	TARGET_OBJ_EXT=$(O)
 	TARGET_OBJ_SUBDIR=$(OS_SUBDIR)
 endif
+endif
 OBJS =	$(OBJ_PROGS:%=$(TARGET_OBJ_SUBDIR)%.$(TARGET_OBJ_EXT)) \
 		$(IL_PROGS:%=$(ILS_SUBDIR)%.il)

Index: tests/valid/flatten_conj_bug.m
===================================================================
RCS file: /home/mercury/mercury1/repository/tests/valid/flatten_conj_bug.m,v
retrieving revision 1.1
diff -u -r1.1 flatten_conj_bug.m
--- tests/valid/flatten_conj_bug.m	3 Aug 2005 12:04:46 -0000	1.1
+++ tests/valid/flatten_conj_bug.m	6 Jun 2007 01:40:35 -0000
@@ -29,5 +29,7 @@

 :- pragma foreign_proc("C", unsafe_any_to_cvar(X::in) = (Y::out(cvar)),
     [will_not_call_mercury, promise_pure], "Y = X;").
+:- pragma foreign_proc("Erlang", unsafe_any_to_cvar(X::in) = (Y::out(cvar)),
+    [will_not_call_mercury, promise_pure], "Y = X").


Index: tests/general/string_format_test_2.exp5
===================================================================
RCS file: tests/general/string_format_test_2.exp5
diff -N tests/general/string_format_test_2.exp5
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ tests/general/string_format_test_2.exp5	6 Jun 2007 01:46:04 -0000
@@ -0,0 +1,6 @@
+Uncaught Mercury exception:
+Software Error: string.format: format string invalid.
+Stack dump follows:
+	mercury__exception:-throw_impl_1_p_0/1-fun-0-/1
+	mercury__io:format_4_p_0/2
+	string_format_test_2:mercury__main_wrapper/0
Index: tests/general/string_format_test_3.exp5
===================================================================
RCS file: tests/general/string_format_test_3.exp5
diff -N tests/general/string_format_test_3.exp5
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ tests/general/string_format_test_3.exp5	6 Jun 2007 01:46:04 -0000
@@ -0,0 +1,8 @@
+Uncaught Mercury exception:
+Software Error: string.format: invalid conversion specifier.
+Stack dump follows:
+	mercury__exception:-throw_impl_1_p_0/1-fun-0-/1
+	mercury__string:format_string_to_specifiers_5_p_0/2
+	mercury__string:format_3_p_0/2
+	mercury__io:format_4_p_0/2
+	string_format_test_3:mercury__main_wrapper/0
Index: tests/hard_coded/exceptions/test_uncaught_exception.exp5
===================================================================
RCS file: tests/hard_coded/exceptions/test_uncaught_exception.exp5
diff -N tests/hard_coded/exceptions/test_uncaught_exception.exp5
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ tests/hard_coded/exceptions/test_uncaught_exception.exp5	6 Jun
2007 01:46:04 -0000
@@ -0,0 +1,5 @@
+Uncaught Mercury exception:
+"<exception thrown from main>"
+Stack dump follows:
+	mercury__exception:-throw_impl_1_p_0/1-fun-0-/1
+	test_uncaught_exception:mercury__main_wrapper/0
Index: tests/hard_coded/no_fully_strict.exp5
===================================================================
RCS file: tests/hard_coded/no_fully_strict.exp5
diff -N tests/hard_coded/no_fully_strict.exp5
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ tests/hard_coded/no_fully_strict.exp5	6 Jun 2007 01:46:04 -0000
@@ -0,0 +1,5 @@
+Uncaught Mercury exception:
+Software Error: oops
+Stack dump follows:
+	mercury__exception:-throw_impl_1_p_0/1-fun-0-/1
+	no_fully_strict:mercury__main_wrapper/0
--------------------------------------------------------------------------
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