[m-rev.] diff: move tests/invalid/foreign_type to hard_coded

Fergus Henderson fjh at cs.mu.OZ.AU
Mon Aug 26 14:19:39 AEST 2002


Branches: main
Estimated hours taken: 0.25

tests/invalid/Mmakefile:
tests/invalid/foreign_type.m:
tests/invalid/foreign_type.err_exp:
tests/hard_coded/Mmakefile:
tests/hard_coded/foreign_type3.m:
tests/hard_coded/foreign_type3.exp:
	Move tests/invalid/foreign_type.m to tests/hard_coded/foreign_type3.m.
	The code in this test case is legal, ever since my change to allow
	non-word-sized C foreign_types.

Workspace: /home/ceres/fjh/ws-ceres2/mercury
Index: tests/hard_coded/Mmakefile
===================================================================
RCS file: /home/mercury1/repository/tests/hard_coded/Mmakefile,v
retrieving revision 1.164
diff -u -d -r1.164 Mmakefile
--- tests/hard_coded/Mmakefile	20 Aug 2002 00:44:18 -0000	1.164
+++ tests/hard_coded/Mmakefile	26 Aug 2002 04:17:29 -0000
@@ -59,6 +59,7 @@
 	foreign_import_module \
 	foreign_type \
 	foreign_type2 \
+	foreign_type3 \
 	frameopt_pragma_redirect \
 	free_free_mode \
 	func_and_pred \
Index: tests/hard_coded/foreign_type3.exp
===================================================================
RCS file: tests/hard_coded/foreign_type3.exp
diff -N tests/hard_coded/foreign_type3.exp
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ tests/hard_coded/foreign_type3.exp	26 Aug 2002 04:18:20 -0000
@@ -0,0 +1 @@
+Success.
Index: tests/hard_coded/foreign_type3.m
===================================================================
RCS file: tests/hard_coded/foreign_type3.m
diff -N tests/hard_coded/foreign_type3.m
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ tests/hard_coded/foreign_type3.m	26 Aug 2002 04:18:06 -0000
@@ -0,0 +1,58 @@
+% This tests (not very well) the use of C enum and struct foreign types.
+
+:- module foreign_type3.
+
+:- interface.
+
+:- import_module io.
+
+:- pred main(io__state::di, io__state::uo) is det.
+
+:- implementation.
+
+main -->
+	{ _C = new(1, 2) },
+	{ _E = north },
+	{ _Pi = pi },
+	io__write_string("Success.\n").
+
+:- pragma foreign_decl(c, "
+typedef enum {
+	north,
+	east,
+	west,
+	south,
+} dirs;
+
+typedef struct {
+	int x, y;
+} coord;
+").
+
+:- type dir.
+:- pragma foreign_type(c, dir, "dirs").
+
+:- type coord.
+:- pragma foreign_type(c, coord, "coord").
+
+:- type double.
+:- pragma foreign_type(c, double, "double").
+
+:- func north = dir.
+:- pragma foreign_proc(c, 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),
+		[will_not_call_mercury, promise_pure], "
+	C.x = X;
+	C.y = Y;
+").
+
+:- func pi = double.
+:- pragma foreign_proc(c, pi = (Pi::out),
+		[will_not_call_mercury, promise_pure], "
+	Pi = 3.14;
+").
Index: tests/invalid/Mmakefile
===================================================================
RCS file: /home/mercury1/repository/tests/invalid/Mmakefile,v
retrieving revision 1.120
diff -u -d -r1.120 Mmakefile
--- tests/invalid/Mmakefile	17 Aug 2002 13:52:19 -0000	1.120
+++ tests/invalid/Mmakefile	26 Aug 2002 04:15:32 -0000
@@ -150,8 +150,6 @@
 #	ho_default_func_4 (due to a bug in the mode-checker ---
 #			see XXX comment in inst_match:inst_matches_final_3)
 #	inst_matches_final_bug (due to same bug as ho_default_func_4)
-#	foreign_type (the error is only detected when trying to compile 
-#		the generated C code).
 
 #-----------------------------------------------------------------------------#
 
Index: tests/invalid/foreign_type.err_exp
===================================================================
RCS file: tests/invalid/foreign_type.err_exp
diff -N tests/invalid/foreign_type.err_exp
Index: tests/invalid/foreign_type.m
===================================================================
RCS file: tests/invalid/foreign_type.m
diff -N tests/invalid/foreign_type.m
--- tests/invalid/foreign_type.m	7 May 2002 11:02:43 -0000	1.1
+++ /dev/null	1 Jan 1970 00:00:00 -0000
@@ -1,56 +0,0 @@
-:- module foreign_type.
-
-:- interface.
-
-:- import_module io.
-
-:- pred main(io__state::di, io__state::uo) is det.
-
-:- implementation.
-
-main -->
-	{ _C = new(1, 2) },
-	{ _E = north },
-	{ _Pi = pi },
-	io__write_string("Success.\n").
-
-:- pragma foreign_decl(c, "
-typedef enum {
-	north,
-	east,
-	west,
-	south,
-} dirs;
-
-typedef struct {
-	int x, y;
-} coord;
-").
-
-:- type dir.
-:- pragma foreign_type(c, dir, "dirs").
-
-:- type coord.
-:- pragma foreign_type(c, coord, "coord").
-
-:- type double.
-:- pragma foreign_type(c, double, "double").
-
-:- func north = dir.
-:- pragma foreign_proc(c, 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),
-		[will_not_call_mercury, promise_pure], "
-	C.x = X;
-	C.y = Y;
-").
-
-:- func pi = double.
-:- pragma foreign_proc(c, pi = (Pi::out),
-		[will_not_call_mercury, promise_pure], "
-	Pi = 3.14;
-").

-- 
Fergus Henderson <fjh at cs.mu.oz.au>  |  "I have always known that the pursuit
The University of Melbourne         |  of excellence is a lethal habit"
WWW: <http://www.cs.mu.oz.au/~fjh>  |     -- the last words of T. S. Garp.
--------------------------------------------------------------------------
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