[m-rev.] diff: add structure reuse tests

Peter Ross peter.ross at miscrit.be
Fri Mar 30 20:43:56 AEST 2001


Hi,

This is the start of the test suite for the structure reuse phase.  Note
that the tests *haven't* been linked in with the main test suite, so
are not automically done as part of the nightly tests.

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


Estimated hours taken: 0.5
Branches: main

Add a directory for structure reuse tests.  This change doesn't
cause these tests to be automatically run as part of the full test suite.

Mmakefile:
runtests:
    General testing framework files.
    
internal_alias.exp:
internal_alias.m:
    Check that we record internal aliases between different parts of the
    same data structure.


Index: Mmakefile
===================================================================
RCS file: Mmakefile
diff -N Mmakefile
--- /dev/null	Sat Aug  7 21:45:41 1999
+++ Mmakefile	Fri Mar 30 20:40:00 2001
@@ -0,0 +1,58 @@
+#-----------------------------------------------------------------------------#
+
+main_target: check
+
+include ../../Mmake.common
+-include ../../Mmake.params
+
+#-----------------------------------------------------------------------------#
+
+ifeq ($(HAVE_NUPROLOG),yes)
+%.exp: %.nu
+	{ [ -f $*.inp ] && cat $*.inp; } | ./$< > $@ 2>&1;
+endif
+
+#-----------------------------------------------------------------------------#
+
+# Any program added here should also be added to the `.cvsignore' file.
+
+PROGS=	internal_alias
+
+ACC_FLAGS = --infer-structure-reuse -d structure_reuse -D sr
+
+	# Optimizations to turn off/on.
+OPT_FLAGS = --no-static-ground-terms
+
+	# Ensure that the accumulator introduction flags are passed
+	# after EXTRA_MCFLAGS, so that we can override things set in
+	# EXTRA_MCFLAGS.
+#ALL_MCDFLAGS+= $(ACC_FLAGS)
+#ALL_MCGFLAGS+= $(OPT_FLAGS) $(ACC_FLAGS)
+EXTRA_MCFLAGS+= $(OPT_FLAGS) $(ACC_FLAGS)
+
+    # programs which aren't working.
+NOT_WORKING =
+
+DEPENDS=$(PROGS:%=%.depend)
+OUTS=	$(PROGS:%=%.out)
+EXPS=	$(PROGS:%=%.exp)
+RESS=	$(PROGS:%=%.res)
+MODS=	$(PROGS:%=%.mod)
+
+depend: $(DEPENDS)
+
+exp:	$(EXPS)
+
+check:	$(OUTS) $(RESS)
+
+mods:	$(MODS)
+
+all:	$(PROGS)
+
+realclean_local: clean_hlds_dump
+
+clean_hlds_dump:
+	-rm -f *hlds_dump*
+	-rm -f *.profile
+
+#-----------------------------------------------------------------------------#
Index: internal_alias.exp
===================================================================
RCS file: internal_alias.exp
diff -N internal_alias.exp
--- /dev/null	Sat Aug  7 21:45:41 1999
+++ internal_alias.exp	Fri Mar 30 20:40:00 2001
@@ -0,0 +1 @@
+pp(p(2.00000000000000, 2.00000000000000), p(0.500000000000000, 0.500000000000000))
Index: internal_alias.m
===================================================================
RCS file: internal_alias.m
diff -N internal_alias.m
--- /dev/null	Sat Aug  7 21:45:41 1999
+++ internal_alias.m	Fri Mar 30 20:40:00 2001
@@ -0,0 +1,41 @@
+%-----------------------------------------------------------------------------%
+%
+% The function identity creates an internal alias between the 2 fields of pp,
+% thus we cannot reuse the individual fields of pp when calling scale as
+% both fields point to the same memory cell.
+%
+%-----------------------------------------------------------------------------%
+:- module internal_alias.
+
+:- interface.
+
+:- import_module io.
+
+:- pred main(io__state::di, io__state::uo) is det.
+
+:- implementation.
+
+:- import_module float.
+
+:- type point
+	--->	p(float, float).
+
+:- type point_pair
+	--->	pp(point, point).
+
+main -->
+	io__write(scale(2.0, identity)),
+	io__nl.
+
+:- func identity = point_pair.
+
+identity = pp(P, P) :- P = p(1.0, 1.0).
+
+:- func scale(float, point_pair) = point_pair.
+
+scale(Factor, pp(A0, B0)) = pp(A, B) :-
+	A0 = p(X, Y),
+	A =  p(Factor * X, Factor * Y),
+
+	B0 = p(X0, Y0),
+	B =  p((1.0/Factor) * X0, (1.0/Factor) * Y0).
Index: runtests
===================================================================
RCS file: runtests
diff -N runtests
--- /dev/null	Sat Aug  7 21:45:41 1999
+++ runtests	Fri Mar 30 20:40:00 2001
@@ -0,0 +1,37 @@
+#!/bin/sh
+# Test whether the code generated by the Mercury compiler is producing 
+# the same output as code generated by the NU-Prolog compiler.
+# Return a status of 0 (true) if everything is all right, and 1 otherwise.
+#
+# The .exp files containing the expected output of each test should be under
+# CVS control. They can be updated by running
+#
+#	mmake realclean
+#	mmake depend
+#	mmake exp
+#
+# on a machine that has NU-Prolog installed.
+
+. ../../handle_options
+. ../../startup
+
+eval mmake $mmakeopts depend || exit 1
+eval mmake $mmakeopts -k check
+checkstatus=$?
+
+cat *.res > .allres
+if test ! -s .allres -a "$checkstatus" = 0
+then
+	echo "the tests in the general/accumulator directory succeeded"
+	echo "mmakeopts=$mmakeopts"
+	rm -f .allres INTRODUCED.diff
+	. ../../shutdown
+	exit 0
+else
+	echo "** the tests in the general/accumulator directory failed"
+	echo "** as some test cases didn't produce the correct output"
+	echo "mmakeopts=$mmakeopts"
+	echo "the differences are:"
+	cat .allres
+	exit 1
+fi

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