[m-rev.] diff: add erlang data representation test case

Peter Ross pro at missioncriticalit.com
Wed Jun 6 16:47:44 AEST 2007


Hi,

We currently fail this test on the erlang back-end, but add
the test case so that we eventually fix this.


===================================================================


Estimated hours taken: 0.25
Branches: main


hard_coded/Mmakefile:
hard_coded/erlang_deconstruct.exp:
hard_coded/erlang_deconstruct.m:
	Check that we correctly distinguish between two functors
	which have the same functor and the same *real* arity
	(including existential type information).

Index: hard_coded/Mmakefile
===================================================================
RCS file: /home/mercury1/repository/tests/hard_coded/Mmakefile,v
retrieving revision 1.319
diff -u -r1.319 Mmakefile
--- hard_coded/Mmakefile	6 Jun 2007 01:48:10 -0000	1.319
+++ hard_coded/Mmakefile	6 Jun 2007 06:42:53 -0000
@@ -62,6 +62,7 @@
 	elim_special_pred \
 	equality_pred_which_requires_boxing \
 	eqv_type_bug \
+	erlang_deconstruct \
 	erroneous_liveness \
 	error_func \
 	existential_bound_tvar \
Index: hard_coded/erlang_deconstruct.exp
===================================================================
RCS file: hard_coded/erlang_deconstruct.exp
diff -N hard_coded/erlang_deconstruct.exp
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ hard_coded/erlang_deconstruct.exp	6 Jun 2007 06:42:53 -0000
@@ -0,0 +1,2 @@
+f/1
+f/2
Index: hard_coded/erlang_deconstruct.m
===================================================================
RCS file: hard_coded/erlang_deconstruct.m
diff -N hard_coded/erlang_deconstruct.m
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ hard_coded/erlang_deconstruct.m	6 Jun 2007 06:42:53 -0000
@@ -0,0 +1,37 @@
+%
+% both alternatives of the type t are represented by tuples of size 3 on
+% the erlang backend, make sure the compiler distinguishes between
+% them correctly.
+%
+:- module erlang_deconstruct.
+:- interface.
+:- import_module io.
+:- pred main(io::di, io::uo) is det.
+:- implementation.
+
+:- import_module int.
+
+:- type t
+    --->    f(int, int)
+    ;       some [T] f(T)
+    .
+
+main(!IO) :-
+    check_t(create(0), !IO),
+    check_t(create(100), !IO).
+
+:- pred check_t(t::in, io::di, io::uo) is det.
+
+check_t(f(_, _), !IO) :-
+    io.write_string("f/2\n", !IO).
+check_t(f(_), !IO) :-
+    io.write_string("f/1\n", !IO).
+
+:- func create(int) = t.
+
+create(N) =
+    ( abs(N) > 10 ->
+        f(1, 1)
+    ;
+        'new f'("string")
+    ).

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