[m-rev.] for review: recursive_main new test case

James Goddard goddardjames at yahoo.com
Mon Dec 22 15:54:06 AEDT 2003


Estimated hours taken: 1
Branches: main

Added a test case to ensure that main can be called recursively without any
problems.  It is also an additional IO test.

tests/hard-coded/recursive_main.m:
	Test program that just echoes stdin.

tests/hard-coded/recursive_main.inp:
	Some text input.

tests/hard-coded/recursive_main.exp:
	The exact same text as recursive_main.inp.

tests/hard-coded/Mmakefile:
	Added recursive_main to the enabled lists.


Index: Mmakefile
===================================================================
RCS file: /home/mercury1/repository/tests/hard_coded/Mmakefile,v
retrieving revision 1.215
diff -u -d -r1.215 Mmakefile
--- Mmakefile	19 Dec 2003 02:43:59 -0000	1.215
+++ Mmakefile	22 Dec 2003 04:43:57 -0000
@@ -130,6 +130,7 @@
 	random_permutation \
 	random_simple \
 	rational_test \
+	recursive_main \
 	redoip_clobber \
 	relation_test \
 	remove_file \
@@ -210,6 +211,7 @@
 	nondet_copy_out \
 	pragma_inline \
 	qual_basic_test \
+	recursive_main \
 	reorder_di \
 	rev_arith \
 	reverse_arith \
Index: recursive_main.exp
===================================================================
RCS file: recursive_main.exp
diff -N recursive_main.exp
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ recursive_main.exp	22 Dec 2003 03:44:43 -0000
@@ -0,0 +1 @@
+This is a test.
Index: recursive_main.inp
===================================================================
RCS file: recursive_main.inp
diff -N recursive_main.inp
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ recursive_main.inp	22 Dec 2003 03:44:31 -0000
@@ -0,0 +1 @@
+This is a test.
Index: recursive_main.m
===================================================================
RCS file: recursive_main.m
diff -N recursive_main.m
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ recursive_main.m	22 Dec 2003 04:49:06 -0000
@@ -0,0 +1,30 @@
+% All this program does is echo the input by recursively calling main to read
+% and then write one char.
+%
+% It is useful both for ensuring that this recursion works ok, and as an IO
+% test.
+
+:- module recursive_main.
+
+:- interface.
+
+:- import_module io.
+
+:- pred main(io__state::di, io__state::uo) is det.
+
+:- implementation.
+
+:- import_module io.
+
+main -->
+	read_char(Result),
+	(
+		{ Result = ok(Char) },
+		write_char(Char),
+		main
+	;
+		{ Result = eof }
+	;
+		{ Result = error(Error) },
+		write_string(error_message(Error))
+	).
--------------------------------------------------------------------------
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