From d64781a3d79fd5502c8484eba40f1aced5ddacac Mon Sep 17 00:00:00 2001 From: Tyson Dowd Date: Mon, 14 Feb 2000 05:28:45 +0000 Subject: [PATCH] Add a testing architecture for the samples directory. Estimated hours taken: 15 Add a testing architecture for the samples directory. The tests are in the "tests" subdirectory of the samples directory. This keeps them close to the samples, but not close enough to clutter up the samples. It also means you don't have to worry about the issue of exactly where the developer has checked out the CVS tests module. samples/c_interface/simpler_c_calls_mercury/Mmakefile: Update this example to generate a .a file instead of directly using $(mercury_lib.os) samples/tests/*: Test cases for all the samples. --- .../simpler_c_calls_mercury/Mmakefile | 10 +- samples/tests/Mmake.common | 96 +++++++++++++++++++ samples/tests/Mmake.common.samples | 78 +++++++++++++++ samples/tests/Mmakefile | 37 +++++++ samples/tests/c_interface/Mmake.thisdir | 6 ++ samples/tests/c_interface/Mmakefile | 14 +++ .../c_interface/c_calls_mercury/Mmake.thisdir | 6 ++ .../c_interface/c_calls_mercury/Mmakefile | 29 ++++++ .../c_calls_mercury/mercury_main.exp | 15 +++ .../c_interface/c_calls_mercury/runtests | 47 +++++++++ .../cplusplus_calls_mercury/Mmake.thisdir | 6 ++ .../cplusplus_calls_mercury/mercury_main.exp | 15 +++ .../cplusplus_calls_mercury/runtests | 47 +++++++++ .../c_interface/mercury_calls_c/Mmake.thisdir | 6 ++ .../c_interface/mercury_calls_c/Mmakefile | 27 ++++++ .../mercury_calls_c/mercury_main.exp | 3 + .../c_interface/mercury_calls_c/runtests | 47 +++++++++ .../mercury_calls_cplusplus/Mmake.thisdir | 6 ++ .../mercury_calls_cplusplus/Mmakefile | 27 ++++++ .../mercury_calls_cplusplus/mercury_main.exp | 3 + .../mercury_calls_cplusplus/runtests | 47 +++++++++ .../mercury_calls_fortran/Mmake.thisdir | 6 ++ .../mercury_calls_fortran/Mmakefile | 28 ++++++ .../mercury_calls_fortran/mercury_main.exp | 3 + .../mercury_calls_fortran/runtests | 47 +++++++++ samples/tests/c_interface/runtests | 47 +++++++++ samples/tests/c_interface/short_example.exp | 2 + .../simpler_c_calls_mercury/Mmake.thisdir | 6 ++ .../simpler_c_calls_mercury/Mmakefile | 27 ++++++ .../simpler_c_calls_mercury/c_main.exp | 13 +++ .../simpler_c_calls_mercury/runtests | 47 +++++++++ .../Mmake.thisdir | 6 ++ .../simpler_cplusplus_calls_mercury/Mmakefile | 27 ++++++ .../cpp_main.exp | 13 +++ .../simpler_cplusplus_calls_mercury/runtests | 47 +++++++++ samples/tests/diff/Mmake.thisdir | 6 ++ samples/tests/diff/Mmakefile | 16 ++++ samples/tests/diff/diff.arg | 1 + samples/tests/diff/diff.exp | 10 ++ samples/tests/diff/diff.test.1 | 5 + samples/tests/diff/diff.test.2 | 7 ++ samples/tests/diff/runtests | 47 +++++++++ samples/tests/generate_exp | 15 +++ samples/tests/handle_options | 84 ++++++++++++++++ samples/tests/muz/Mmake.thisdir | 6 ++ samples/tests/muz/Mmakefile | 17 ++++ samples/tests/muz/muz.arg | 1 + samples/tests/muz/muz.exp | 1 + samples/tests/muz/runtests | 47 +++++++++ samples/tests/rot13/Mmake.thisdir | 6 ++ samples/tests/rot13/Mmakefile | 17 ++++ samples/tests/rot13/rot13_concise.exp | 2 + samples/tests/rot13/rot13_concise.inp | 2 + samples/tests/rot13/rot13_gustavo.exp | 2 + samples/tests/rot13/rot13_gustavo.inp | 2 + samples/tests/rot13/rot13_juergen.exp | 2 + samples/tests/rot13/rot13_juergen.inp | 2 + samples/tests/rot13/rot13_verbose.exp | 2 + samples/tests/rot13/rot13_verbose.inp | 2 + samples/tests/rot13/runtests | 45 +++++++++ samples/tests/runtests | 18 ++++ samples/tests/shutdown | 4 + samples/tests/solutions/Mmake.thisdir | 6 ++ samples/tests/solutions/Mmakefile | 17 ++++ samples/tests/solutions/all_solutions.exp | 2 + samples/tests/solutions/one_solution.exp | 1 + samples/tests/solutions/runtests | 47 +++++++++ samples/tests/solutions/some_solutions.exp | 4 + samples/tests/solutions/some_solutions.inp | 3 + samples/tests/startup | 8 ++ samples/tests/subdir_runtests | 20 ++++ samples/tests/toplevel/Mmake.thisdir | 6 ++ samples/tests/toplevel/Mmakefile | 20 ++++ samples/tests/toplevel/calculator.exp | 2 + samples/tests/toplevel/calculator.inp | 1 + samples/tests/toplevel/cat.exp | 2 + samples/tests/toplevel/cat.inp | 2 + samples/tests/toplevel/e.exp | 13 +++ samples/tests/toplevel/eliza.exp | 12 +++ samples/tests/toplevel/eliza.inp | 2 + samples/tests/toplevel/expand_terms.exp | 1 + samples/tests/toplevel/expand_terms.inp | 1 + samples/tests/toplevel/hello.exp | 1 + samples/tests/toplevel/interpreter.arg | 1 + samples/tests/toplevel/interpreter.exp | 7 ++ samples/tests/toplevel/interpreter.inp | 2 + samples/tests/toplevel/interpreter_test.pl | 16 ++++ samples/tests/toplevel/runtests | 47 +++++++++ samples/tests/toplevel/sort.exp | 4 + samples/tests/toplevel/sort.inp | 4 + samples/tests/toplevel/ultra_sub.arg | 1 + samples/tests/toplevel/ultra_sub.exp | 1 + samples/tests/toplevel/ultra_sub.inp | 1 + 93 files changed, 1511 insertions(+), 4 deletions(-) create mode 100644 samples/tests/Mmake.common create mode 100644 samples/tests/Mmake.common.samples create mode 100644 samples/tests/Mmakefile create mode 100644 samples/tests/c_interface/Mmake.thisdir create mode 100644 samples/tests/c_interface/Mmakefile create mode 100644 samples/tests/c_interface/c_calls_mercury/Mmake.thisdir create mode 100644 samples/tests/c_interface/c_calls_mercury/Mmakefile create mode 100644 samples/tests/c_interface/c_calls_mercury/mercury_main.exp create mode 100755 samples/tests/c_interface/c_calls_mercury/runtests create mode 100644 samples/tests/c_interface/cplusplus_calls_mercury/Mmake.thisdir create mode 100644 samples/tests/c_interface/cplusplus_calls_mercury/mercury_main.exp create mode 100755 samples/tests/c_interface/cplusplus_calls_mercury/runtests create mode 100644 samples/tests/c_interface/mercury_calls_c/Mmake.thisdir create mode 100644 samples/tests/c_interface/mercury_calls_c/Mmakefile create mode 100644 samples/tests/c_interface/mercury_calls_c/mercury_main.exp create mode 100755 samples/tests/c_interface/mercury_calls_c/runtests create mode 100644 samples/tests/c_interface/mercury_calls_cplusplus/Mmake.thisdir create mode 100644 samples/tests/c_interface/mercury_calls_cplusplus/Mmakefile create mode 100644 samples/tests/c_interface/mercury_calls_cplusplus/mercury_main.exp create mode 100755 samples/tests/c_interface/mercury_calls_cplusplus/runtests create mode 100644 samples/tests/c_interface/mercury_calls_fortran/Mmake.thisdir create mode 100644 samples/tests/c_interface/mercury_calls_fortran/Mmakefile create mode 100644 samples/tests/c_interface/mercury_calls_fortran/mercury_main.exp create mode 100755 samples/tests/c_interface/mercury_calls_fortran/runtests create mode 100755 samples/tests/c_interface/runtests create mode 100644 samples/tests/c_interface/short_example.exp create mode 100644 samples/tests/c_interface/simpler_c_calls_mercury/Mmake.thisdir create mode 100644 samples/tests/c_interface/simpler_c_calls_mercury/Mmakefile create mode 100644 samples/tests/c_interface/simpler_c_calls_mercury/c_main.exp create mode 100755 samples/tests/c_interface/simpler_c_calls_mercury/runtests create mode 100644 samples/tests/c_interface/simpler_cplusplus_calls_mercury/Mmake.thisdir create mode 100644 samples/tests/c_interface/simpler_cplusplus_calls_mercury/Mmakefile create mode 100644 samples/tests/c_interface/simpler_cplusplus_calls_mercury/cpp_main.exp create mode 100755 samples/tests/c_interface/simpler_cplusplus_calls_mercury/runtests create mode 100644 samples/tests/diff/Mmake.thisdir create mode 100644 samples/tests/diff/Mmakefile create mode 100644 samples/tests/diff/diff.arg create mode 100644 samples/tests/diff/diff.exp create mode 100644 samples/tests/diff/diff.test.1 create mode 100644 samples/tests/diff/diff.test.2 create mode 100755 samples/tests/diff/runtests create mode 100755 samples/tests/generate_exp create mode 100644 samples/tests/handle_options create mode 100644 samples/tests/muz/Mmake.thisdir create mode 100644 samples/tests/muz/Mmakefile create mode 100644 samples/tests/muz/muz.arg create mode 100644 samples/tests/muz/muz.exp create mode 100755 samples/tests/muz/runtests create mode 100644 samples/tests/rot13/Mmake.thisdir create mode 100644 samples/tests/rot13/Mmakefile create mode 100644 samples/tests/rot13/rot13_concise.exp create mode 100644 samples/tests/rot13/rot13_concise.inp create mode 100644 samples/tests/rot13/rot13_gustavo.exp create mode 100644 samples/tests/rot13/rot13_gustavo.inp create mode 100644 samples/tests/rot13/rot13_juergen.exp create mode 100644 samples/tests/rot13/rot13_juergen.inp create mode 100644 samples/tests/rot13/rot13_verbose.exp create mode 100644 samples/tests/rot13/rot13_verbose.inp create mode 100755 samples/tests/rot13/runtests create mode 100755 samples/tests/runtests create mode 100644 samples/tests/shutdown create mode 100644 samples/tests/solutions/Mmake.thisdir create mode 100644 samples/tests/solutions/Mmakefile create mode 100644 samples/tests/solutions/all_solutions.exp create mode 100644 samples/tests/solutions/one_solution.exp create mode 100755 samples/tests/solutions/runtests create mode 100644 samples/tests/solutions/some_solutions.exp create mode 100644 samples/tests/solutions/some_solutions.inp create mode 100644 samples/tests/startup create mode 100644 samples/tests/subdir_runtests create mode 100644 samples/tests/toplevel/Mmake.thisdir create mode 100644 samples/tests/toplevel/Mmakefile create mode 100644 samples/tests/toplevel/calculator.exp create mode 100644 samples/tests/toplevel/calculator.inp create mode 100644 samples/tests/toplevel/cat.exp create mode 100644 samples/tests/toplevel/cat.inp create mode 100644 samples/tests/toplevel/e.exp create mode 100644 samples/tests/toplevel/eliza.exp create mode 100644 samples/tests/toplevel/eliza.inp create mode 100644 samples/tests/toplevel/expand_terms.exp create mode 100644 samples/tests/toplevel/expand_terms.inp create mode 100644 samples/tests/toplevel/hello.exp create mode 100644 samples/tests/toplevel/interpreter.arg create mode 100644 samples/tests/toplevel/interpreter.exp create mode 100644 samples/tests/toplevel/interpreter.inp create mode 100644 samples/tests/toplevel/interpreter_test.pl create mode 100755 samples/tests/toplevel/runtests create mode 100644 samples/tests/toplevel/sort.exp create mode 100644 samples/tests/toplevel/sort.inp create mode 100644 samples/tests/toplevel/ultra_sub.arg create mode 100644 samples/tests/toplevel/ultra_sub.exp create mode 100644 samples/tests/toplevel/ultra_sub.inp diff --git a/samples/c_interface/simpler_c_calls_mercury/Mmakefile b/samples/c_interface/simpler_c_calls_mercury/Mmakefile index 517a32aad..16024c5e5 100644 --- a/samples/c_interface/simpler_c_calls_mercury/Mmakefile +++ b/samples/c_interface/simpler_c_calls_mercury/Mmakefile @@ -7,10 +7,12 @@ MAIN_TARGET=all depend: mercury_lib.depend all: c_main -OBJECTS = c_main.o mercury_lib_init.o $(mercury_lib.os) +OBJECTS = c_main.o mercury_lib_init.o +LIBS = libmercury_lib +LIBSLINK = libmercury_lib.a -c_main: $(OBJECTS) - $(ML) $(MLFLAGS) -o c_main $(OBJECTS) $(MLLIBS) +c_main: $(OBJECTS) $(LIBS) + $(ML) $(MLFLAGS) -o c_main $(OBJECTS) $(LIBSLINK) #-----------------------------------------------------------------------------# @@ -26,7 +28,7 @@ RM_C=: #-----------------------------------------------------------------------------# -c_main.o: mercury_lib.h +c_main.o: mercury_lib.h c_main.c # to make mercury_lib.h, just compile mercury_lib.m; # the Mercury compiler will create mercury_lib.h as a side-effect. diff --git a/samples/tests/Mmake.common b/samples/tests/Mmake.common new file mode 100644 index 000000000..a922ced3d --- /dev/null +++ b/samples/tests/Mmake.common @@ -0,0 +1,96 @@ +#-----------------------------------------------------------------------------# + +# +# Note: Mmake lets you override MCFLAGS for a particular file by setting +# MCFLAGS-foo. Similarly, you can override GRADEFLAGS for a particular +# file by setting both GRADEFLAGS-foo and (for compiling the foo_init.c +# file) GRADEFLAGS-foo_init. +# + +# override this with `mmake HAVE_NUPROLOG=yes' +# if you want to rebuild the `.exp' files. +HAVE_NUPROLOG=no + +DIFF_OPTS=-c + +#-----------------------------------------------------------------------------# + +# .PRECIOUS: %.mod %.c %.o %_init.c %.no %.nu %_init.nl %_init.no + +%_init.c: Entry + +# +# If there is a `.inp' file, then we pipe that in as the command's input. +# If there is a `.arg' file, then we use it as the command's argument +# string. +# Then we run the command, with stdout and stderr both redirected to the +# `.out' file. Finally if the command fails (returns non-zero exit status), +# we print out the contents of the `.out' file. We use `grep . $@ /dev/null' +# to print out the contents, because that precedes each line of output with +# the filename, which is helpful when running a parallel make. +# +%.out: % + { [ -f $*.inp ] && cat $*.inp; } | \ + ./$< `{ [ -f $*.arg ] && cat $*.arg; }` > $@ 2>&1 || \ + { grep . $@ /dev/null; exit 1; } + +# +# For some test cases, there is more than one valid output. +# We try matching the output with the `.exp' file, and if that +# doesn't succeed, and there is a `.exp2' file, then we try matching +# against that too. If neither succeed, the shorter of the two diffs +# is put into the `.res' file. +# +%.res: %.exp %.out + -rm -f $@ + -rm -f $*.res2 + diff $(DIFF_OPTS) $*.exp $*.out > $@ || \ + { test -f $*.exp2 && \ + if diff $(DIFF_OPTS) $*.exp2 $*.out > $*.res2; then \ + cp $*.res2 $@; \ + else \ + { test `wc -l < $@` -le `wc -l < $*.res2` || \ + cp $*.res2 $@; } && false; \ + fi; \ + } + +#-----------------------------------------------------------------------------# + +clean_local: clean_out clean_res + +clean_mc: clean_c clean_o clean_out clean_res + +clean_out: + rm -f *.out + +clean_exp: + rm -f *.exp + +clean_res: + rm -f *.res + rm -f *.res2 + +# +# The `foo' targets make `foo_local' in the current directory before +# recursively making `foo' in all subdirectories. The recursive part +# is handled in individual Mmakefiles. +# + +.PHONY: check_local dep_local depend_local all_local + +.PHONY: check_subdirs dep_subdirs depend_subdirs realclean_subdirs \ + clean_subdirs all_subdirs + +check: check_local check_subdirs +dep: dep_local dep_subdirs +depend: depend_local depend_subdirs +realclean: realclean_subdirs +clean: clean_subdirs +all: all_local all_subdirs + +SUBDIR_MMAKE = mmake \ + GRADE='$(GRADE)' \ + EXTRA_CFLAGS='$(EXTRA_CFLAGS)' \ + EXTRA_MCFLAGS='$(EXTRA_MCFLAGS)' + +#-----------------------------------------------------------------------------# diff --git a/samples/tests/Mmake.common.samples b/samples/tests/Mmake.common.samples new file mode 100644 index 000000000..4101ab89f --- /dev/null +++ b/samples/tests/Mmake.common.samples @@ -0,0 +1,78 @@ + +#-----------------------------------------------------------------------------# + +SOURCEDIR=$(DEPTH)/../$(THISDIR) + +%.m: $(SOURCEDIR)/%.m + cp $(SOURCEDIR)/$@ . + +SOURCEDIR_EXTRA_FILES= $(EXTRA_FILES:%=$(SOURCEDIR)/%) + +#-----------------------------------------------------------------------------# + +SRCS= $(PROGS:%=%.m) +DEPS= $(PROGS:%=%.dep) +DEPENDS=$(PROGS:%=%.depend) +OUTS= $(PROGS:%=%.out) $(TESTS:%=%.out) +RESS= $(PROGS:%=%.res) $(TESTS:%=%.res) + +dep_local: $(DEPS) +depend_local: extra_files $(SRCS) $(DEPENDS) +check_local: $(OUTS) $(RESS) +all_local: $(PROGS) $(TESTS) + +clean_local: clean_srcs clean_extra_files + +clean_srcs: + rm -f $(SRCS) + +clean_extra_files: + rm -f $(EXTRA_FILES) + +extra_files: $(SOURCEDIR_EXTRA_FILES) + -{ [ -n "$(SOURCEDIR_EXTRA_FILES)" ] && cp $(SOURCEDIR_EXTRA_FILES) . || true ; } + +#-----------------------------------------------------------------------------# + +realclean: + rm -f $(SRCS) $(EXTRA_FILES) + +SUBDIRS = + +ifeq ($(SUBDIRS),"") + +dep_subdirs: + for dir in $(SUBDIRS); do \ + (cd $$dir && $(SUBDIR_MMAKE) dep) || exit 1; \ + done + +depend_subdirs: + for dir in $(SUBDIRS); do \ + (cd $$dir && $(SUBDIR_MMAKE) depend) || exit 1; \ + done + +check_subdirs: + for dir in $(SUBDIRS); do \ + (cd $$dir && $(SUBDIR_MMAKE) check) || exit 1; \ + done + +all_subdirs: + for dir in $(SUBDIRS); do \ + (cd $$dir && $(SUBDIR_MMAKE) all) || exit 1; \ + done + +clean_subdirs: + for dir in $(SUBDIRS); do \ + (cd $$dir && $(SUBDIR_MMAKE) clean) || exit 1; \ + done + +realclean_subdirs: + for dir in $(SUBDIRS); do \ + (cd $$dir && $(SUBDIR_MMAKE) realclean) || exit 1; \ + done + +else + +endif + +#-----------------------------------------------------------------------------# diff --git a/samples/tests/Mmakefile b/samples/tests/Mmakefile new file mode 100644 index 000000000..6d255e128 --- /dev/null +++ b/samples/tests/Mmakefile @@ -0,0 +1,37 @@ +SUBDIRS = benchmarks general hard_coded invalid misc_tests tabling term valid warnings +NUPROLOG_SUBDIRS = benchmarks general + +main_target: check + +# Generate the .exp files that are used as a basis of comparison to check +# the correctness of the code emitted by the Mercury compiler. +exp: + for dir in $(NUPROLOG_SUBDIRS); do \ + (cd $$dir && mmake $(MMAKEFLAGS) exp) || exit 1; \ + done + +# run the tests +check: + for dir in $(SUBDIRS); do \ + (cd $$dir && mmake $(MMAKEFLAGS) check) || exit 1; \ + done + +dep: + for dir in $(SUBDIRS); do \ + (cd $$dir && mmake $(MMAKEFLAGS) dep) || exit 1; \ + done + +depend: + for dir in $(SUBDIRS); do \ + (cd $$dir && mmake $(MMAKEFLAGS) depend) || exit 1; \ + done + +realclean: + for dir in $(SUBDIRS); do \ + (cd $$dir && mmake $(MMAKEFLAGS) realclean) || exit 1; \ + done + +clean: + for dir in $(SUBDIRS); do \ + (cd $$dir && mmake $(MMAKEFLAGS) clean) || exit 1; \ + done diff --git a/samples/tests/c_interface/Mmake.thisdir b/samples/tests/c_interface/Mmake.thisdir new file mode 100644 index 000000000..c83d53904 --- /dev/null +++ b/samples/tests/c_interface/Mmake.thisdir @@ -0,0 +1,6 @@ +#-----------------------------------------------------------------------------# + +DEPTH=.. +THISDIR=c_interface + +#-----------------------------------------------------------------------------# diff --git a/samples/tests/c_interface/Mmakefile b/samples/tests/c_interface/Mmakefile new file mode 100644 index 000000000..01723c266 --- /dev/null +++ b/samples/tests/c_interface/Mmakefile @@ -0,0 +1,14 @@ +#-----------------------------------------------------------------------------# + +main_target: check + +PROGS=short_example +TESTS= + +EXTRA_FILES= + +include Mmake.thisdir +include $(DEPTH)/Mmake.common +include $(DEPTH)/Mmake.common.samples + +#-----------------------------------------------------------------------------# diff --git a/samples/tests/c_interface/c_calls_mercury/Mmake.thisdir b/samples/tests/c_interface/c_calls_mercury/Mmake.thisdir new file mode 100644 index 000000000..151e6b4d5 --- /dev/null +++ b/samples/tests/c_interface/c_calls_mercury/Mmake.thisdir @@ -0,0 +1,6 @@ +#-----------------------------------------------------------------------------# + +DEPTH=../.. +THISDIR=c_interface/c_calls_mercury + +#-----------------------------------------------------------------------------# diff --git a/samples/tests/c_interface/c_calls_mercury/Mmakefile b/samples/tests/c_interface/c_calls_mercury/Mmakefile new file mode 100644 index 000000000..7372ac8be --- /dev/null +++ b/samples/tests/c_interface/c_calls_mercury/Mmakefile @@ -0,0 +1,29 @@ +#-----------------------------------------------------------------------------# + +main_target: check + +PROGS=mercury_main +TESTS= + +EXTRA_FILES=c_main.c c_main.h + +include Mmake.thisdir +include $(DEPTH)/Mmake.common +include $(DEPTH)/Mmake.common.samples + +#-----------------------------------------------------------------------------# + +include $(SOURCEDIR)/Mmakefile + +# Add a few dependencies so that it copies the source +# files correctly. +mercury_lib.o: mercury_lib.m +mercury_main.depend: c_main_int.m +c_main_int.o: c_main.h + +clean_local: clean_2 + +clean_2: + rm -f *.h *.c *.m mercury_lib.* + +#-----------------------------------------------------------------------------# diff --git a/samples/tests/c_interface/c_calls_mercury/mercury_main.exp b/samples/tests/c_interface/c_calls_mercury/mercury_main.exp new file mode 100644 index 000000000..21befd9a7 --- /dev/null +++ b/samples/tests/c_interface/c_calls_mercury/mercury_main.exp @@ -0,0 +1,15 @@ +In Mercury main, about to call c_main... +In c_main(). +foo_test(42) returns TRUE +foo_test(43) returns FALSE +one_foo(&value) gives value = 42 +foo_list() = [42, 53, 197] +bar(100) = 101 +bar_test(100, 101) returns TRUE +bar_test(100, 200) returns FALSE +bar_inverse(&value, 101) gives value = 100 +bar_inverse(&value, 200) gives value = 199 +baz(1, &value) returns TRUE with value = 9 +baz(100, &value) returns FALSE +Returning from c_main()... +Back in Mercury main. diff --git a/samples/tests/c_interface/c_calls_mercury/runtests b/samples/tests/c_interface/c_calls_mercury/runtests new file mode 100755 index 000000000..814c576c2 --- /dev/null +++ b/samples/tests/c_interface/c_calls_mercury/runtests @@ -0,0 +1,47 @@ +#!/bin/sh +# Test whether the code generated by the Mercury compiler +# is producing the expected output. +# Return a status of 0 (true) if everything is all right, and 1 otherwise. + +. Mmake.thisdir + +. $DEPTH/handle_options + +# Run the tests in any subdirectories of this one. If any of these +# fail, we still perform the tests in this directory but return a +# status of 1 regardless of the outcome. + +. $DEPTH/subdir_runtests + +if test "$subdir_failures" = "" +then + subdir_status=0 +else + subdir_status=1 +fi + +# Now run all the tests in this directory. +. $DEPTH/startup + +eval mmake $mmakeopts depend_local || exit 1 +eval mmake -k $mmakeopts check_local +checkstatus=$? + +pwdir=`pwd` +thisdirname=`basename $pwdir` + +cat *.res > .allres +if test ! -s .allres -a "$checkstatus" = 0 +then + echo "the tests in the $thisdirname directory succeeded" + echo "mmakeopts=$mmakeopts" + rm -f .allres + . $DEPTH/shutdown + exit $subdir_status +else + echo "the tests in the $thisdirname directory failed" + echo "mmakeopts=$mmakeopts" + echo "the differences are:" + cat .allres + exit 1 +fi diff --git a/samples/tests/c_interface/cplusplus_calls_mercury/Mmake.thisdir b/samples/tests/c_interface/cplusplus_calls_mercury/Mmake.thisdir new file mode 100644 index 000000000..12548a39d --- /dev/null +++ b/samples/tests/c_interface/cplusplus_calls_mercury/Mmake.thisdir @@ -0,0 +1,6 @@ +#-----------------------------------------------------------------------------# + +DEPTH=../.. +THISDIR=c_interface/cplusplus_calls_mercury + +#-----------------------------------------------------------------------------# diff --git a/samples/tests/c_interface/cplusplus_calls_mercury/mercury_main.exp b/samples/tests/c_interface/cplusplus_calls_mercury/mercury_main.exp new file mode 100644 index 000000000..af4c5059e --- /dev/null +++ b/samples/tests/c_interface/cplusplus_calls_mercury/mercury_main.exp @@ -0,0 +1,15 @@ +In Mercury main, about to call cpp_main... +In cpp_main(). +foo_test(42) returns TRUE +foo_test(43) returns FALSE +one_foo(&value) gives value = 42 +foo_list() = [42, 53, 197] +bar(100) = 101 +bar_test(100, 101) returns TRUE +bar_test(100, 200) returns FALSE +bar_inverse(&value, 101) gives value = 100 +bar_inverse(&value, 200) gives value = 199 +baz(1, &value) returns TRUE with value = 9 +baz(100, &value) returns FALSE +Returning from cpp_main()... +Back in Mercury main. diff --git a/samples/tests/c_interface/cplusplus_calls_mercury/runtests b/samples/tests/c_interface/cplusplus_calls_mercury/runtests new file mode 100755 index 000000000..814c576c2 --- /dev/null +++ b/samples/tests/c_interface/cplusplus_calls_mercury/runtests @@ -0,0 +1,47 @@ +#!/bin/sh +# Test whether the code generated by the Mercury compiler +# is producing the expected output. +# Return a status of 0 (true) if everything is all right, and 1 otherwise. + +. Mmake.thisdir + +. $DEPTH/handle_options + +# Run the tests in any subdirectories of this one. If any of these +# fail, we still perform the tests in this directory but return a +# status of 1 regardless of the outcome. + +. $DEPTH/subdir_runtests + +if test "$subdir_failures" = "" +then + subdir_status=0 +else + subdir_status=1 +fi + +# Now run all the tests in this directory. +. $DEPTH/startup + +eval mmake $mmakeopts depend_local || exit 1 +eval mmake -k $mmakeopts check_local +checkstatus=$? + +pwdir=`pwd` +thisdirname=`basename $pwdir` + +cat *.res > .allres +if test ! -s .allres -a "$checkstatus" = 0 +then + echo "the tests in the $thisdirname directory succeeded" + echo "mmakeopts=$mmakeopts" + rm -f .allres + . $DEPTH/shutdown + exit $subdir_status +else + echo "the tests in the $thisdirname directory failed" + echo "mmakeopts=$mmakeopts" + echo "the differences are:" + cat .allres + exit 1 +fi diff --git a/samples/tests/c_interface/mercury_calls_c/Mmake.thisdir b/samples/tests/c_interface/mercury_calls_c/Mmake.thisdir new file mode 100644 index 000000000..261b4ea4f --- /dev/null +++ b/samples/tests/c_interface/mercury_calls_c/Mmake.thisdir @@ -0,0 +1,6 @@ +#-----------------------------------------------------------------------------# + +DEPTH=../.. +THISDIR=c_interface/mercury_calls_c + +#-----------------------------------------------------------------------------# diff --git a/samples/tests/c_interface/mercury_calls_c/Mmakefile b/samples/tests/c_interface/mercury_calls_c/Mmakefile new file mode 100644 index 000000000..3d9930897 --- /dev/null +++ b/samples/tests/c_interface/mercury_calls_c/Mmakefile @@ -0,0 +1,27 @@ +#-----------------------------------------------------------------------------# + +main_target: check + +PROGS=mercury_main +TESTS= + +EXTRA_FILES=c_main.c c_main.h + +include Mmake.thisdir +include $(DEPTH)/Mmake.common +include $(DEPTH)/Mmake.common.samples + +#-----------------------------------------------------------------------------# + +include $(SOURCEDIR)/Mmakefile + +# Add a few dependencies so that it copies the source +# files correctly. +mercury_main.depend: c_main_int.m + +clean_local: clean_2 + +clean_2: + rm -f *.m + +#-----------------------------------------------------------------------------# diff --git a/samples/tests/c_interface/mercury_calls_c/mercury_main.exp b/samples/tests/c_interface/mercury_calls_c/mercury_main.exp new file mode 100644 index 000000000..5786f0715 --- /dev/null +++ b/samples/tests/c_interface/mercury_calls_c/mercury_main.exp @@ -0,0 +1,3 @@ +In Mercury main, about to call c_main... +In c_main(). +Back in Mercury main. diff --git a/samples/tests/c_interface/mercury_calls_c/runtests b/samples/tests/c_interface/mercury_calls_c/runtests new file mode 100755 index 000000000..814c576c2 --- /dev/null +++ b/samples/tests/c_interface/mercury_calls_c/runtests @@ -0,0 +1,47 @@ +#!/bin/sh +# Test whether the code generated by the Mercury compiler +# is producing the expected output. +# Return a status of 0 (true) if everything is all right, and 1 otherwise. + +. Mmake.thisdir + +. $DEPTH/handle_options + +# Run the tests in any subdirectories of this one. If any of these +# fail, we still perform the tests in this directory but return a +# status of 1 regardless of the outcome. + +. $DEPTH/subdir_runtests + +if test "$subdir_failures" = "" +then + subdir_status=0 +else + subdir_status=1 +fi + +# Now run all the tests in this directory. +. $DEPTH/startup + +eval mmake $mmakeopts depend_local || exit 1 +eval mmake -k $mmakeopts check_local +checkstatus=$? + +pwdir=`pwd` +thisdirname=`basename $pwdir` + +cat *.res > .allres +if test ! -s .allres -a "$checkstatus" = 0 +then + echo "the tests in the $thisdirname directory succeeded" + echo "mmakeopts=$mmakeopts" + rm -f .allres + . $DEPTH/shutdown + exit $subdir_status +else + echo "the tests in the $thisdirname directory failed" + echo "mmakeopts=$mmakeopts" + echo "the differences are:" + cat .allres + exit 1 +fi diff --git a/samples/tests/c_interface/mercury_calls_cplusplus/Mmake.thisdir b/samples/tests/c_interface/mercury_calls_cplusplus/Mmake.thisdir new file mode 100644 index 000000000..943954bc7 --- /dev/null +++ b/samples/tests/c_interface/mercury_calls_cplusplus/Mmake.thisdir @@ -0,0 +1,6 @@ +#-----------------------------------------------------------------------------# + +DEPTH=../.. +THISDIR=c_interface/mercury_calls_cplusplus + +#-----------------------------------------------------------------------------# diff --git a/samples/tests/c_interface/mercury_calls_cplusplus/Mmakefile b/samples/tests/c_interface/mercury_calls_cplusplus/Mmakefile new file mode 100644 index 000000000..30f91b08b --- /dev/null +++ b/samples/tests/c_interface/mercury_calls_cplusplus/Mmakefile @@ -0,0 +1,27 @@ +#-----------------------------------------------------------------------------# + +main_target: check + +PROGS=mercury_main +TESTS= + +EXTRA_FILES=cpp_main.c cpp_main.h + +include Mmake.thisdir +include $(DEPTH)/Mmake.common +include $(DEPTH)/Mmake.common.samples + +#-----------------------------------------------------------------------------# + +include $(SOURCEDIR)/Mmakefile + +# Add a few dependencies so that it copies the source +# files correctly. +mercury_main.depend: cpp_main_int.m + +clean_local: clean_2 + +clean_2: + rm -f *.m + +#-----------------------------------------------------------------------------# diff --git a/samples/tests/c_interface/mercury_calls_cplusplus/mercury_main.exp b/samples/tests/c_interface/mercury_calls_cplusplus/mercury_main.exp new file mode 100644 index 000000000..b8c73a999 --- /dev/null +++ b/samples/tests/c_interface/mercury_calls_cplusplus/mercury_main.exp @@ -0,0 +1,3 @@ +In Mercury main, about to call cpp_main... +In cpp_main(). +Back in Mercury main. diff --git a/samples/tests/c_interface/mercury_calls_cplusplus/runtests b/samples/tests/c_interface/mercury_calls_cplusplus/runtests new file mode 100755 index 000000000..814c576c2 --- /dev/null +++ b/samples/tests/c_interface/mercury_calls_cplusplus/runtests @@ -0,0 +1,47 @@ +#!/bin/sh +# Test whether the code generated by the Mercury compiler +# is producing the expected output. +# Return a status of 0 (true) if everything is all right, and 1 otherwise. + +. Mmake.thisdir + +. $DEPTH/handle_options + +# Run the tests in any subdirectories of this one. If any of these +# fail, we still perform the tests in this directory but return a +# status of 1 regardless of the outcome. + +. $DEPTH/subdir_runtests + +if test "$subdir_failures" = "" +then + subdir_status=0 +else + subdir_status=1 +fi + +# Now run all the tests in this directory. +. $DEPTH/startup + +eval mmake $mmakeopts depend_local || exit 1 +eval mmake -k $mmakeopts check_local +checkstatus=$? + +pwdir=`pwd` +thisdirname=`basename $pwdir` + +cat *.res > .allres +if test ! -s .allres -a "$checkstatus" = 0 +then + echo "the tests in the $thisdirname directory succeeded" + echo "mmakeopts=$mmakeopts" + rm -f .allres + . $DEPTH/shutdown + exit $subdir_status +else + echo "the tests in the $thisdirname directory failed" + echo "mmakeopts=$mmakeopts" + echo "the differences are:" + cat .allres + exit 1 +fi diff --git a/samples/tests/c_interface/mercury_calls_fortran/Mmake.thisdir b/samples/tests/c_interface/mercury_calls_fortran/Mmake.thisdir new file mode 100644 index 000000000..89f624b17 --- /dev/null +++ b/samples/tests/c_interface/mercury_calls_fortran/Mmake.thisdir @@ -0,0 +1,6 @@ +#-----------------------------------------------------------------------------# + +DEPTH=../.. +THISDIR=c_interface/mercury_calls_fortran + +#-----------------------------------------------------------------------------# diff --git a/samples/tests/c_interface/mercury_calls_fortran/Mmakefile b/samples/tests/c_interface/mercury_calls_fortran/Mmakefile new file mode 100644 index 000000000..28df47804 --- /dev/null +++ b/samples/tests/c_interface/mercury_calls_fortran/Mmakefile @@ -0,0 +1,28 @@ +#-----------------------------------------------------------------------------# + +main_target: check + +PROGS=mercury_main +TESTS= + +EXTRA_FILES=fortran_main.f + +include Mmake.thisdir +include $(DEPTH)/Mmake.common +include $(DEPTH)/Mmake.common.samples + +#-----------------------------------------------------------------------------# + +include $(SOURCEDIR)/Mmakefile + +# Add a few dependencies so that it copies the source +# files correctly. +mercury_main.depend: fortran_main_int.m +#fortran_main_int.o: fortran_main.f + +clean_local: clean_2 + +clean_2: + rm -f *.m + +#-----------------------------------------------------------------------------# diff --git a/samples/tests/c_interface/mercury_calls_fortran/mercury_main.exp b/samples/tests/c_interface/mercury_calls_fortran/mercury_main.exp new file mode 100644 index 000000000..671452c1b --- /dev/null +++ b/samples/tests/c_interface/mercury_calls_fortran/mercury_main.exp @@ -0,0 +1,3 @@ +In Mercury main, about to call fortran_main... + In FORTRAN_MAIN +Back in Mercury main. diff --git a/samples/tests/c_interface/mercury_calls_fortran/runtests b/samples/tests/c_interface/mercury_calls_fortran/runtests new file mode 100755 index 000000000..814c576c2 --- /dev/null +++ b/samples/tests/c_interface/mercury_calls_fortran/runtests @@ -0,0 +1,47 @@ +#!/bin/sh +# Test whether the code generated by the Mercury compiler +# is producing the expected output. +# Return a status of 0 (true) if everything is all right, and 1 otherwise. + +. Mmake.thisdir + +. $DEPTH/handle_options + +# Run the tests in any subdirectories of this one. If any of these +# fail, we still perform the tests in this directory but return a +# status of 1 regardless of the outcome. + +. $DEPTH/subdir_runtests + +if test "$subdir_failures" = "" +then + subdir_status=0 +else + subdir_status=1 +fi + +# Now run all the tests in this directory. +. $DEPTH/startup + +eval mmake $mmakeopts depend_local || exit 1 +eval mmake -k $mmakeopts check_local +checkstatus=$? + +pwdir=`pwd` +thisdirname=`basename $pwdir` + +cat *.res > .allres +if test ! -s .allres -a "$checkstatus" = 0 +then + echo "the tests in the $thisdirname directory succeeded" + echo "mmakeopts=$mmakeopts" + rm -f .allres + . $DEPTH/shutdown + exit $subdir_status +else + echo "the tests in the $thisdirname directory failed" + echo "mmakeopts=$mmakeopts" + echo "the differences are:" + cat .allres + exit 1 +fi diff --git a/samples/tests/c_interface/runtests b/samples/tests/c_interface/runtests new file mode 100755 index 000000000..814c576c2 --- /dev/null +++ b/samples/tests/c_interface/runtests @@ -0,0 +1,47 @@ +#!/bin/sh +# Test whether the code generated by the Mercury compiler +# is producing the expected output. +# Return a status of 0 (true) if everything is all right, and 1 otherwise. + +. Mmake.thisdir + +. $DEPTH/handle_options + +# Run the tests in any subdirectories of this one. If any of these +# fail, we still perform the tests in this directory but return a +# status of 1 regardless of the outcome. + +. $DEPTH/subdir_runtests + +if test "$subdir_failures" = "" +then + subdir_status=0 +else + subdir_status=1 +fi + +# Now run all the tests in this directory. +. $DEPTH/startup + +eval mmake $mmakeopts depend_local || exit 1 +eval mmake -k $mmakeopts check_local +checkstatus=$? + +pwdir=`pwd` +thisdirname=`basename $pwdir` + +cat *.res > .allres +if test ! -s .allres -a "$checkstatus" = 0 +then + echo "the tests in the $thisdirname directory succeeded" + echo "mmakeopts=$mmakeopts" + rm -f .allres + . $DEPTH/shutdown + exit $subdir_status +else + echo "the tests in the $thisdirname directory failed" + echo "mmakeopts=$mmakeopts" + echo "the differences are:" + cat .allres + exit 1 +fi diff --git a/samples/tests/c_interface/short_example.exp b/samples/tests/c_interface/short_example.exp new file mode 100644 index 000000000..0c9bdb6ff --- /dev/null +++ b/samples/tests/c_interface/short_example.exp @@ -0,0 +1,2 @@ +Hello, world + diff --git a/samples/tests/c_interface/simpler_c_calls_mercury/Mmake.thisdir b/samples/tests/c_interface/simpler_c_calls_mercury/Mmake.thisdir new file mode 100644 index 000000000..023dc1e2f --- /dev/null +++ b/samples/tests/c_interface/simpler_c_calls_mercury/Mmake.thisdir @@ -0,0 +1,6 @@ +#-----------------------------------------------------------------------------# + +DEPTH=../.. +THISDIR=c_interface/simpler_c_calls_mercury + +#-----------------------------------------------------------------------------# diff --git a/samples/tests/c_interface/simpler_c_calls_mercury/Mmakefile b/samples/tests/c_interface/simpler_c_calls_mercury/Mmakefile new file mode 100644 index 000000000..7fc266f09 --- /dev/null +++ b/samples/tests/c_interface/simpler_c_calls_mercury/Mmakefile @@ -0,0 +1,27 @@ +#-----------------------------------------------------------------------------# +# +main_target: check + +PROGS= +TESTS=c_main + +EXTRA_FILES=c_main.c + +include Mmake.thisdir +include $(DEPTH)/Mmake.common +include $(DEPTH)/Mmake.common.samples + +#-----------------------------------------------------------------------------# + +depend_local: mercury_lib.depend + +mercury_lib.depend: mercury_lib.m + +include $(SOURCEDIR)/Mmakefile + +clean_local: clean_2 + +clean_2: + rm -f *.h *.c *.m mercury_lib.* + +#-----------------------------------------------------------------------------# diff --git a/samples/tests/c_interface/simpler_c_calls_mercury/c_main.exp b/samples/tests/c_interface/simpler_c_calls_mercury/c_main.exp new file mode 100644 index 000000000..684abcb91 --- /dev/null +++ b/samples/tests/c_interface/simpler_c_calls_mercury/c_main.exp @@ -0,0 +1,13 @@ +In main(). +foo_test(42) returns TRUE +foo_test(43) returns FALSE +one_foo(&value) gives value = 42 +foo_list() = [42, 53, 197] +bar(100) = 101 +bar_test(100, 101) returns TRUE +bar_test(100, 200) returns FALSE +bar_inverse(&value, 101) gives value = 100 +bar_inverse(&value, 200) gives value = 199 +baz(1, &value) returns TRUE with value = 9 +baz(100, &value) returns FALSE +Returning from main(). diff --git a/samples/tests/c_interface/simpler_c_calls_mercury/runtests b/samples/tests/c_interface/simpler_c_calls_mercury/runtests new file mode 100755 index 000000000..814c576c2 --- /dev/null +++ b/samples/tests/c_interface/simpler_c_calls_mercury/runtests @@ -0,0 +1,47 @@ +#!/bin/sh +# Test whether the code generated by the Mercury compiler +# is producing the expected output. +# Return a status of 0 (true) if everything is all right, and 1 otherwise. + +. Mmake.thisdir + +. $DEPTH/handle_options + +# Run the tests in any subdirectories of this one. If any of these +# fail, we still perform the tests in this directory but return a +# status of 1 regardless of the outcome. + +. $DEPTH/subdir_runtests + +if test "$subdir_failures" = "" +then + subdir_status=0 +else + subdir_status=1 +fi + +# Now run all the tests in this directory. +. $DEPTH/startup + +eval mmake $mmakeopts depend_local || exit 1 +eval mmake -k $mmakeopts check_local +checkstatus=$? + +pwdir=`pwd` +thisdirname=`basename $pwdir` + +cat *.res > .allres +if test ! -s .allres -a "$checkstatus" = 0 +then + echo "the tests in the $thisdirname directory succeeded" + echo "mmakeopts=$mmakeopts" + rm -f .allres + . $DEPTH/shutdown + exit $subdir_status +else + echo "the tests in the $thisdirname directory failed" + echo "mmakeopts=$mmakeopts" + echo "the differences are:" + cat .allres + exit 1 +fi diff --git a/samples/tests/c_interface/simpler_cplusplus_calls_mercury/Mmake.thisdir b/samples/tests/c_interface/simpler_cplusplus_calls_mercury/Mmake.thisdir new file mode 100644 index 000000000..d63c66853 --- /dev/null +++ b/samples/tests/c_interface/simpler_cplusplus_calls_mercury/Mmake.thisdir @@ -0,0 +1,6 @@ +#-----------------------------------------------------------------------------# + +DEPTH=../.. +THISDIR=c_interface/simpler_cplusplus_calls_mercury + +#-----------------------------------------------------------------------------# diff --git a/samples/tests/c_interface/simpler_cplusplus_calls_mercury/Mmakefile b/samples/tests/c_interface/simpler_cplusplus_calls_mercury/Mmakefile new file mode 100644 index 000000000..f9524ebb5 --- /dev/null +++ b/samples/tests/c_interface/simpler_cplusplus_calls_mercury/Mmakefile @@ -0,0 +1,27 @@ +#-----------------------------------------------------------------------------# +# +main_target: check + +PROGS= +TESTS=cpp_main + +EXTRA_FILES=cpp_main.cc + +include Mmake.thisdir +include $(DEPTH)/Mmake.common +include $(DEPTH)/Mmake.common.samples + +#-----------------------------------------------------------------------------# + +depend_local: mercury_lib.depend + +mercury_lib.depend: mercury_lib.m + +include $(SOURCEDIR)/Mmakefile + +clean_local: clean_2 + +clean_2: + rm -f *.h *.c *.m mercury_lib.* + +#-----------------------------------------------------------------------------# diff --git a/samples/tests/c_interface/simpler_cplusplus_calls_mercury/cpp_main.exp b/samples/tests/c_interface/simpler_cplusplus_calls_mercury/cpp_main.exp new file mode 100644 index 000000000..684abcb91 --- /dev/null +++ b/samples/tests/c_interface/simpler_cplusplus_calls_mercury/cpp_main.exp @@ -0,0 +1,13 @@ +In main(). +foo_test(42) returns TRUE +foo_test(43) returns FALSE +one_foo(&value) gives value = 42 +foo_list() = [42, 53, 197] +bar(100) = 101 +bar_test(100, 101) returns TRUE +bar_test(100, 200) returns FALSE +bar_inverse(&value, 101) gives value = 100 +bar_inverse(&value, 200) gives value = 199 +baz(1, &value) returns TRUE with value = 9 +baz(100, &value) returns FALSE +Returning from main(). diff --git a/samples/tests/c_interface/simpler_cplusplus_calls_mercury/runtests b/samples/tests/c_interface/simpler_cplusplus_calls_mercury/runtests new file mode 100755 index 000000000..814c576c2 --- /dev/null +++ b/samples/tests/c_interface/simpler_cplusplus_calls_mercury/runtests @@ -0,0 +1,47 @@ +#!/bin/sh +# Test whether the code generated by the Mercury compiler +# is producing the expected output. +# Return a status of 0 (true) if everything is all right, and 1 otherwise. + +. Mmake.thisdir + +. $DEPTH/handle_options + +# Run the tests in any subdirectories of this one. If any of these +# fail, we still perform the tests in this directory but return a +# status of 1 regardless of the outcome. + +. $DEPTH/subdir_runtests + +if test "$subdir_failures" = "" +then + subdir_status=0 +else + subdir_status=1 +fi + +# Now run all the tests in this directory. +. $DEPTH/startup + +eval mmake $mmakeopts depend_local || exit 1 +eval mmake -k $mmakeopts check_local +checkstatus=$? + +pwdir=`pwd` +thisdirname=`basename $pwdir` + +cat *.res > .allres +if test ! -s .allres -a "$checkstatus" = 0 +then + echo "the tests in the $thisdirname directory succeeded" + echo "mmakeopts=$mmakeopts" + rm -f .allres + . $DEPTH/shutdown + exit $subdir_status +else + echo "the tests in the $thisdirname directory failed" + echo "mmakeopts=$mmakeopts" + echo "the differences are:" + cat .allres + exit 1 +fi diff --git a/samples/tests/diff/Mmake.thisdir b/samples/tests/diff/Mmake.thisdir new file mode 100644 index 000000000..a9b2f53e1 --- /dev/null +++ b/samples/tests/diff/Mmake.thisdir @@ -0,0 +1,6 @@ +#-----------------------------------------------------------------------------# + +DEPTH=.. +THISDIR=diff + +#-----------------------------------------------------------------------------# diff --git a/samples/tests/diff/Mmakefile b/samples/tests/diff/Mmakefile new file mode 100644 index 000000000..4b7fd0607 --- /dev/null +++ b/samples/tests/diff/Mmakefile @@ -0,0 +1,16 @@ +#-----------------------------------------------------------------------------# + +main_target: check + +PROGS=diff +TESTS= + +EXTRA_FILES=diff_out.m difftype.m file.m filter.m globals.m \ + match.m myers.m options.m + +include Mmake.thisdir +include $(DEPTH)/Mmake.common +include $(DEPTH)/Mmake.common.samples + + +#-----------------------------------------------------------------------------# diff --git a/samples/tests/diff/diff.arg b/samples/tests/diff/diff.arg new file mode 100644 index 000000000..bb5047104 --- /dev/null +++ b/samples/tests/diff/diff.arg @@ -0,0 +1 @@ +-u diff.test.1 diff.test.2 diff --git a/samples/tests/diff/diff.exp b/samples/tests/diff/diff.exp new file mode 100644 index 000000000..da2406d77 --- /dev/null +++ b/samples/tests/diff/diff.exp @@ -0,0 +1,10 @@ +--- diff.test.1 ++++ diff.test.2 +@@ -1,5 +1,7 @@ + Hello + World + ++How interesting an additional line ++ + This + is a test diff --git a/samples/tests/diff/diff.test.1 b/samples/tests/diff/diff.test.1 new file mode 100644 index 000000000..9effda740 --- /dev/null +++ b/samples/tests/diff/diff.test.1 @@ -0,0 +1,5 @@ +Hello +World + +This +is a test diff --git a/samples/tests/diff/diff.test.2 b/samples/tests/diff/diff.test.2 new file mode 100644 index 000000000..b6ae0578a --- /dev/null +++ b/samples/tests/diff/diff.test.2 @@ -0,0 +1,7 @@ +Hello +World + +How interesting an additional line + +This +is a test diff --git a/samples/tests/diff/runtests b/samples/tests/diff/runtests new file mode 100755 index 000000000..814c576c2 --- /dev/null +++ b/samples/tests/diff/runtests @@ -0,0 +1,47 @@ +#!/bin/sh +# Test whether the code generated by the Mercury compiler +# is producing the expected output. +# Return a status of 0 (true) if everything is all right, and 1 otherwise. + +. Mmake.thisdir + +. $DEPTH/handle_options + +# Run the tests in any subdirectories of this one. If any of these +# fail, we still perform the tests in this directory but return a +# status of 1 regardless of the outcome. + +. $DEPTH/subdir_runtests + +if test "$subdir_failures" = "" +then + subdir_status=0 +else + subdir_status=1 +fi + +# Now run all the tests in this directory. +. $DEPTH/startup + +eval mmake $mmakeopts depend_local || exit 1 +eval mmake -k $mmakeopts check_local +checkstatus=$? + +pwdir=`pwd` +thisdirname=`basename $pwdir` + +cat *.res > .allres +if test ! -s .allres -a "$checkstatus" = 0 +then + echo "the tests in the $thisdirname directory succeeded" + echo "mmakeopts=$mmakeopts" + rm -f .allres + . $DEPTH/shutdown + exit $subdir_status +else + echo "the tests in the $thisdirname directory failed" + echo "mmakeopts=$mmakeopts" + echo "the differences are:" + cat .allres + exit 1 +fi diff --git a/samples/tests/generate_exp b/samples/tests/generate_exp new file mode 100755 index 000000000..4f2aa2bd4 --- /dev/null +++ b/samples/tests/generate_exp @@ -0,0 +1,15 @@ +#!/bin/sh +# Generate the .exp files that are used as a basis of comparison to check +# the correctness of the code emitted by the Mercury compiler. + +. ./handle_options + +root=`pwd` +for dir in benchmarks general +do + cd $dir + mmake $jfactor realclean + mmake $jfactor depend + mmake $jfactor HAVE_NUPROLOG=yes exp + cd $root +done diff --git a/samples/tests/handle_options b/samples/tests/handle_options new file mode 100644 index 000000000..593a68c1b --- /dev/null +++ b/samples/tests/handle_options @@ -0,0 +1,84 @@ +usage="\ +Usage: $0 [options] +Options: + -f , --flags + Pass EXTRA_MCFLAGS= as an option to \`mmake check'. + -m , --mgnucflags + Pass EXTRA_MGNUCFLAGS= as an option to \`mmake check'. + -c , --cflags + Pass EXTRA_CFLAGS= as an option to \`mmake check'. + -l , --mlflags + Pass EXTRA_MLFLAGS= as an option to \`mmake check'. + -g , --grade + Pass GRADE= as an option to \`mmake check'. + -j , --jobs + Run using different parallel processes. +" + +jfactor="" +flagsopt="" +mgnucflagsopt="" +cflagsopt="" +mlflagsopt="" +gradeopt="" +fflag="" +mflag="" +cflag="" +lflag="" +gflag="" + +while [ $# -gt 0 ]; do + case "$1" in + + -f|--flags) + fflag="-f '$2'" + flagsopt="EXTRA_MCFLAGS='$2'" + shift ;; + + -m|--mgnucflags) + mflag="-m '$2'" + mgnucflagsopt="EXTRA_MGNUCFLAGS='$2'" + shift ;; + + -c|--cflags) + cflag="-c '$2'" + cflagsopt="EXTRA_CFLAGS='$2'" + shift ;; + + -l|--mlflags) + lflag="-l '$2'" + mlflagsopt="EXTRA_MLFLAGS='$2'" + shift ;; + + -g|--grade) + gflag="-g $2" + gradeopt="GRADE=$2" + shift ;; + + -j|--jobs) + jfactor="-j$2"; shift ;; + -j*) + jfactor="-j` expr $1 : '-j\(.*\)' `" ;; + --jobs*) + jfactor="--jobs` expr $1 : '--jobs\(.*\)' `" ;; + + --) + shift; break ;; + -*) + echo "$0: unknown option \`$1'" 1>&2 + echo "$usage" 1>&2 + exit 1 ;; + *) + break ;; + esac + shift +done + +if [ $# -ne 0 ]; then + echo "$0: unexpected argument(s) \`$*'" 1>&2 + echo "$usage" 1>&2 + exit 1 +fi + +mmakeopts="$jfactor $flagsopt $mgnucflagsopt $cflagsopt $mlflagsopt $gradeopt" +runtestopts="$jfactor $mflag $cflag $lflag $fflag $gflag" diff --git a/samples/tests/muz/Mmake.thisdir b/samples/tests/muz/Mmake.thisdir new file mode 100644 index 000000000..eb5a91665 --- /dev/null +++ b/samples/tests/muz/Mmake.thisdir @@ -0,0 +1,6 @@ +#-----------------------------------------------------------------------------# + +DEPTH=.. +THISDIR=muz + +#-----------------------------------------------------------------------------# diff --git a/samples/tests/muz/Mmakefile b/samples/tests/muz/Mmakefile new file mode 100644 index 000000000..8e03e5012 --- /dev/null +++ b/samples/tests/muz/Mmakefile @@ -0,0 +1,17 @@ +#-----------------------------------------------------------------------------# + +main_target: check + +PROGS=muz +TESTS= + +EXTRA_FILES=dict.m example.tex example1.tex higher_order.m muz.m \ + toolkit.tex typecheck.m word.m zabstract.m zlogic.m zparser.m \ + ztoken.m ztoken_io.m ztype.m ztype_op.m + +include Mmake.thisdir +include $(DEPTH)/Mmake.common +include $(DEPTH)/Mmake.common.samples + + +#-----------------------------------------------------------------------------# diff --git a/samples/tests/muz/muz.arg b/samples/tests/muz/muz.arg new file mode 100644 index 000000000..8a502f3f7 --- /dev/null +++ b/samples/tests/muz/muz.arg @@ -0,0 +1 @@ +-t toolkit.tex example.tex diff --git a/samples/tests/muz/muz.exp b/samples/tests/muz/muz.exp new file mode 100644 index 000000000..dc9232661 --- /dev/null +++ b/samples/tests/muz/muz.exp @@ -0,0 +1 @@ +No errors detected. diff --git a/samples/tests/muz/runtests b/samples/tests/muz/runtests new file mode 100755 index 000000000..814c576c2 --- /dev/null +++ b/samples/tests/muz/runtests @@ -0,0 +1,47 @@ +#!/bin/sh +# Test whether the code generated by the Mercury compiler +# is producing the expected output. +# Return a status of 0 (true) if everything is all right, and 1 otherwise. + +. Mmake.thisdir + +. $DEPTH/handle_options + +# Run the tests in any subdirectories of this one. If any of these +# fail, we still perform the tests in this directory but return a +# status of 1 regardless of the outcome. + +. $DEPTH/subdir_runtests + +if test "$subdir_failures" = "" +then + subdir_status=0 +else + subdir_status=1 +fi + +# Now run all the tests in this directory. +. $DEPTH/startup + +eval mmake $mmakeopts depend_local || exit 1 +eval mmake -k $mmakeopts check_local +checkstatus=$? + +pwdir=`pwd` +thisdirname=`basename $pwdir` + +cat *.res > .allres +if test ! -s .allres -a "$checkstatus" = 0 +then + echo "the tests in the $thisdirname directory succeeded" + echo "mmakeopts=$mmakeopts" + rm -f .allres + . $DEPTH/shutdown + exit $subdir_status +else + echo "the tests in the $thisdirname directory failed" + echo "mmakeopts=$mmakeopts" + echo "the differences are:" + cat .allres + exit 1 +fi diff --git a/samples/tests/rot13/Mmake.thisdir b/samples/tests/rot13/Mmake.thisdir new file mode 100644 index 000000000..686b92c88 --- /dev/null +++ b/samples/tests/rot13/Mmake.thisdir @@ -0,0 +1,6 @@ +#-----------------------------------------------------------------------------# + +DEPTH=.. +THISDIR=rot13 + +#-----------------------------------------------------------------------------# diff --git a/samples/tests/rot13/Mmakefile b/samples/tests/rot13/Mmakefile new file mode 100644 index 000000000..aa49c3716 --- /dev/null +++ b/samples/tests/rot13/Mmakefile @@ -0,0 +1,17 @@ +#-----------------------------------------------------------------------------# + +main_target: check + +PROGS= rot13_concise \ + rot13_verbose \ + rot13_gustavo \ + rot13_juergen +TESTS= + +MCFLAGS-rot13_concise=--infer-all + +include Mmake.thisdir +include $(DEPTH)/Mmake.common +include $(DEPTH)/Mmake.common.samples + +#-----------------------------------------------------------------------------# diff --git a/samples/tests/rot13/rot13_concise.exp b/samples/tests/rot13/rot13_concise.exp new file mode 100644 index 000000000..0fe1f53f7 --- /dev/null +++ b/samples/tests/rot13/rot13_concise.exp @@ -0,0 +1,2 @@ +N yvggyr grfg bs gur ebg13 cebtenz. +A little test of the rot13 program. diff --git a/samples/tests/rot13/rot13_concise.inp b/samples/tests/rot13/rot13_concise.inp new file mode 100644 index 000000000..19d92f631 --- /dev/null +++ b/samples/tests/rot13/rot13_concise.inp @@ -0,0 +1,2 @@ +A little test of the rot13 program. +N yvggyr grfg bs gur ebg13 cebtenz. diff --git a/samples/tests/rot13/rot13_gustavo.exp b/samples/tests/rot13/rot13_gustavo.exp new file mode 100644 index 000000000..0fe1f53f7 --- /dev/null +++ b/samples/tests/rot13/rot13_gustavo.exp @@ -0,0 +1,2 @@ +N yvggyr grfg bs gur ebg13 cebtenz. +A little test of the rot13 program. diff --git a/samples/tests/rot13/rot13_gustavo.inp b/samples/tests/rot13/rot13_gustavo.inp new file mode 100644 index 000000000..19d92f631 --- /dev/null +++ b/samples/tests/rot13/rot13_gustavo.inp @@ -0,0 +1,2 @@ +A little test of the rot13 program. +N yvggyr grfg bs gur ebg13 cebtenz. diff --git a/samples/tests/rot13/rot13_juergen.exp b/samples/tests/rot13/rot13_juergen.exp new file mode 100644 index 000000000..0fe1f53f7 --- /dev/null +++ b/samples/tests/rot13/rot13_juergen.exp @@ -0,0 +1,2 @@ +N yvggyr grfg bs gur ebg13 cebtenz. +A little test of the rot13 program. diff --git a/samples/tests/rot13/rot13_juergen.inp b/samples/tests/rot13/rot13_juergen.inp new file mode 100644 index 000000000..19d92f631 --- /dev/null +++ b/samples/tests/rot13/rot13_juergen.inp @@ -0,0 +1,2 @@ +A little test of the rot13 program. +N yvggyr grfg bs gur ebg13 cebtenz. diff --git a/samples/tests/rot13/rot13_verbose.exp b/samples/tests/rot13/rot13_verbose.exp new file mode 100644 index 000000000..0fe1f53f7 --- /dev/null +++ b/samples/tests/rot13/rot13_verbose.exp @@ -0,0 +1,2 @@ +N yvggyr grfg bs gur ebg13 cebtenz. +A little test of the rot13 program. diff --git a/samples/tests/rot13/rot13_verbose.inp b/samples/tests/rot13/rot13_verbose.inp new file mode 100644 index 000000000..19d92f631 --- /dev/null +++ b/samples/tests/rot13/rot13_verbose.inp @@ -0,0 +1,2 @@ +A little test of the rot13 program. +N yvggyr grfg bs gur ebg13 cebtenz. diff --git a/samples/tests/rot13/runtests b/samples/tests/rot13/runtests new file mode 100755 index 000000000..b07f7aff2 --- /dev/null +++ b/samples/tests/rot13/runtests @@ -0,0 +1,45 @@ +#!/bin/sh +# Test whether the code generated by the Mercury compiler +# is producing the expected output. +# Return a status of 0 (true) if everything is all right, and 1 otherwise. + +. ../handle_options + +# Run the tests in any subdirectories of this one. If any of these +# fail, we still perform the tests in this directory but return a +# status of 1 regardless of the outcome. + +. ../subdir_runtests + +if test "$subdir_failures" = "" +then + subdir_status=0 +else + subdir_status=1 +fi + +# Now run all the tests in this directory. +. ../startup + +eval mmake $mmakeopts depend_local || exit 1 +eval mmake -k $mmakeopts check_local +checkstatus=$? + +pwdir=`pwd` +thisdirname=`basename $pwdir` + +cat *.res > .allres +if test ! -s .allres -a "$checkstatus" = 0 +then + echo "the tests in the $thisdirname directory succeeded" + echo "mmakeopts=$mmakeopts" + rm -f .allres + . ../shutdown + exit $subdir_status +else + echo "the tests in the $thisdirname directory failed" + echo "mmakeopts=$mmakeopts" + echo "the differences are:" + cat .allres + exit 1 +fi diff --git a/samples/tests/runtests b/samples/tests/runtests new file mode 100755 index 000000000..e6da8e95d --- /dev/null +++ b/samples/tests/runtests @@ -0,0 +1,18 @@ +#!/bin/sh + +# Process command line options. +. ./handle_options + +# Run the tests in each of the subdirectories. +. ./subdir_runtests + +if test "$subdir_failures" = "" +then + echo "all tests have succeeded" + echo "mmakeopts=$mmakeopts" + exit 0 +else + echo "some tests have failed in: $subdir_failures" + echo "mmakeopts=$mmakeopts" + exit 1 +fi diff --git a/samples/tests/shutdown b/samples/tests/shutdown new file mode 100644 index 000000000..838f8cc8d --- /dev/null +++ b/samples/tests/shutdown @@ -0,0 +1,4 @@ +echo cleaning up the directory after the tests +mmake $gradeopt $jfactor realclean_local > /dev/null 2>&1 +rm core > /dev/null 2>&1 +touch CLEAN diff --git a/samples/tests/solutions/Mmake.thisdir b/samples/tests/solutions/Mmake.thisdir new file mode 100644 index 000000000..aff136d77 --- /dev/null +++ b/samples/tests/solutions/Mmake.thisdir @@ -0,0 +1,6 @@ +#-----------------------------------------------------------------------------# + +DEPTH=.. +THISDIR=solutions + +#-----------------------------------------------------------------------------# diff --git a/samples/tests/solutions/Mmakefile b/samples/tests/solutions/Mmakefile new file mode 100644 index 000000000..7d33528f3 --- /dev/null +++ b/samples/tests/solutions/Mmakefile @@ -0,0 +1,17 @@ +#-----------------------------------------------------------------------------# + +main_target: check + +PROGS= all_solutions \ + one_solution \ + some_solutions +TESTS= + +EXTRA_FILES= + +include Mmake.thisdir +include $(DEPTH)/Mmake.common +include $(DEPTH)/Mmake.common.samples + + +#-----------------------------------------------------------------------------# diff --git a/samples/tests/solutions/all_solutions.exp b/samples/tests/solutions/all_solutions.exp new file mode 100644 index 000000000..60befd035 --- /dev/null +++ b/samples/tests/solutions/all_solutions.exp @@ -0,0 +1,2 @@ +Hello again, world +Hello, world diff --git a/samples/tests/solutions/one_solution.exp b/samples/tests/solutions/one_solution.exp new file mode 100644 index 000000000..a5c196677 --- /dev/null +++ b/samples/tests/solutions/one_solution.exp @@ -0,0 +1 @@ +Hello, world diff --git a/samples/tests/solutions/runtests b/samples/tests/solutions/runtests new file mode 100755 index 000000000..814c576c2 --- /dev/null +++ b/samples/tests/solutions/runtests @@ -0,0 +1,47 @@ +#!/bin/sh +# Test whether the code generated by the Mercury compiler +# is producing the expected output. +# Return a status of 0 (true) if everything is all right, and 1 otherwise. + +. Mmake.thisdir + +. $DEPTH/handle_options + +# Run the tests in any subdirectories of this one. If any of these +# fail, we still perform the tests in this directory but return a +# status of 1 regardless of the outcome. + +. $DEPTH/subdir_runtests + +if test "$subdir_failures" = "" +then + subdir_status=0 +else + subdir_status=1 +fi + +# Now run all the tests in this directory. +. $DEPTH/startup + +eval mmake $mmakeopts depend_local || exit 1 +eval mmake -k $mmakeopts check_local +checkstatus=$? + +pwdir=`pwd` +thisdirname=`basename $pwdir` + +cat *.res > .allres +if test ! -s .allres -a "$checkstatus" = 0 +then + echo "the tests in the $thisdirname directory succeeded" + echo "mmakeopts=$mmakeopts" + rm -f .allres + . $DEPTH/shutdown + exit $subdir_status +else + echo "the tests in the $thisdirname directory failed" + echo "mmakeopts=$mmakeopts" + echo "the differences are:" + cat .allres + exit 1 +fi diff --git a/samples/tests/solutions/some_solutions.exp b/samples/tests/solutions/some_solutions.exp new file mode 100644 index 000000000..9c3055d0f --- /dev/null +++ b/samples/tests/solutions/some_solutions.exp @@ -0,0 +1,4 @@ +Hello, world +More? Good day, world +More? Greetings, world +More? No (more) solutions diff --git a/samples/tests/solutions/some_solutions.inp b/samples/tests/solutions/some_solutions.inp new file mode 100644 index 000000000..a00af2c28 --- /dev/null +++ b/samples/tests/solutions/some_solutions.inp @@ -0,0 +1,3 @@ +y +y +y diff --git a/samples/tests/startup b/samples/tests/startup new file mode 100644 index 000000000..f2c31048a --- /dev/null +++ b/samples/tests/startup @@ -0,0 +1,8 @@ +echo cleaning up the directory before the tests +if ls -lt | head -2 | egrep CLEAN > /dev/null 2>&1 +then + rm -f CLEAN > /dev/null 2>&1 +else + rm -f CLEAN > /dev/null 2>&1 + mmake $gradeopt -j realclean_local > /dev/null 2>&1 +fi diff --git a/samples/tests/subdir_runtests b/samples/tests/subdir_runtests new file mode 100644 index 000000000..3df1136ba --- /dev/null +++ b/samples/tests/subdir_runtests @@ -0,0 +1,20 @@ +# Run the tests in each of the subdirectories. + +subdir_failures="" +for dir in * +do + if test -d $dir -a -x $dir/runtests + then + cd $dir + # we need to use `eval' here to get the quoting right in + # the case when $runtestopts contains embedded spaces + if eval ./runtests $runtestopts + then + true + else + subdir_failures="$subdir_failures $dir" + fi + cd .. + fi +done + diff --git a/samples/tests/toplevel/Mmake.thisdir b/samples/tests/toplevel/Mmake.thisdir new file mode 100644 index 000000000..d302a27a2 --- /dev/null +++ b/samples/tests/toplevel/Mmake.thisdir @@ -0,0 +1,6 @@ +#-----------------------------------------------------------------------------# + +DEPTH=.. +THISDIR=. + +#-----------------------------------------------------------------------------# diff --git a/samples/tests/toplevel/Mmakefile b/samples/tests/toplevel/Mmakefile new file mode 100644 index 000000000..ff4ebe800 --- /dev/null +++ b/samples/tests/toplevel/Mmakefile @@ -0,0 +1,20 @@ +#-----------------------------------------------------------------------------# + +main_target: check + +PROGS= calculator \ + cat \ + e \ + eliza \ + expand_terms \ + hello \ + interpreter \ + sort \ + ultra_sub +TESTS= + +include Mmake.thisdir +include $(DEPTH)/Mmake.common +include $(DEPTH)/Mmake.common.samples + +#-----------------------------------------------------------------------------# diff --git a/samples/tests/toplevel/calculator.exp b/samples/tests/toplevel/calculator.exp new file mode 100644 index 000000000..7b97e1af5 --- /dev/null +++ b/samples/tests/toplevel/calculator.exp @@ -0,0 +1,2 @@ +calculator> 7 +calculator> EOF diff --git a/samples/tests/toplevel/calculator.inp b/samples/tests/toplevel/calculator.inp new file mode 100644 index 000000000..60def52fa --- /dev/null +++ b/samples/tests/toplevel/calculator.inp @@ -0,0 +1 @@ +3+4 diff --git a/samples/tests/toplevel/cat.exp b/samples/tests/toplevel/cat.exp new file mode 100644 index 000000000..989ae080a --- /dev/null +++ b/samples/tests/toplevel/cat.exp @@ -0,0 +1,2 @@ +A test of +the cat program. diff --git a/samples/tests/toplevel/cat.inp b/samples/tests/toplevel/cat.inp new file mode 100644 index 000000000..989ae080a --- /dev/null +++ b/samples/tests/toplevel/cat.inp @@ -0,0 +1,2 @@ +A test of +the cat program. diff --git a/samples/tests/toplevel/e.exp b/samples/tests/toplevel/e.exp new file mode 100644 index 000000000..9d550180f --- /dev/null +++ b/samples/tests/toplevel/e.exp @@ -0,0 +1,13 @@ +2.7182818284590452353602874713526624977572470936999595749669676277240766303535 +475945713821785251664274274663919320030599218174135966290435729003342952605956 +307381323286279434907632338298807531952510190115738341879307021540891499348841 +675092447614606680822648001684774118537423454424371075390777449920695517027618 +386062613313845830007520449338265602976067371132007093287091274437470472306969 +772093101416928368190255151086574637721112523897844250569536967707854499699679 +468644549059879316368892300987931277361782154249992295763514822082698951936680 +331825288693984964651058209392398294887933203625094431173012381970684161403970 +198376793206832823764648042953118023287825098194558153017567173613320698112509 +961818815930416903515988885193458072738667385894228792284998920868058257492796 +104841984443634632449684875602336248270419786232090021609902353043699418491463 +140934317381436405462531520961836908887070167683964243781405927145635490613031 +072085103837505101157477041718986106873969655212671546889570350354 diff --git a/samples/tests/toplevel/eliza.exp b/samples/tests/toplevel/eliza.exp new file mode 100644 index 000000000..faf769b36 --- /dev/null +++ b/samples/tests/toplevel/eliza.exp @@ -0,0 +1,12 @@ + +Hi! I'm Eliza. Please tell me your problem. + +> +Don't you really know mercury? + +> +You seem quite positive. + +> + +Goodbye. diff --git a/samples/tests/toplevel/eliza.inp b/samples/tests/toplevel/eliza.inp new file mode 100644 index 000000000..728c4dbcf --- /dev/null +++ b/samples/tests/toplevel/eliza.inp @@ -0,0 +1,2 @@ +I don't know mercury +yes diff --git a/samples/tests/toplevel/expand_terms.exp b/samples/tests/toplevel/expand_terms.exp new file mode 100644 index 000000000..211efdb50 --- /dev/null +++ b/samples/tests/toplevel/expand_terms.exp @@ -0,0 +1 @@ +A :- B. diff --git a/samples/tests/toplevel/expand_terms.inp b/samples/tests/toplevel/expand_terms.inp new file mode 100644 index 000000000..ae568e50d --- /dev/null +++ b/samples/tests/toplevel/expand_terms.inp @@ -0,0 +1 @@ +A <=> B. diff --git a/samples/tests/toplevel/hello.exp b/samples/tests/toplevel/hello.exp new file mode 100644 index 000000000..a5c196677 --- /dev/null +++ b/samples/tests/toplevel/hello.exp @@ -0,0 +1 @@ +Hello, world diff --git a/samples/tests/toplevel/interpreter.arg b/samples/tests/toplevel/interpreter.arg new file mode 100644 index 000000000..22bff4cc1 --- /dev/null +++ b/samples/tests/toplevel/interpreter.arg @@ -0,0 +1 @@ +interpreter_test.pl diff --git a/samples/tests/toplevel/interpreter.exp b/samples/tests/toplevel/interpreter.exp new file mode 100644 index 000000000..d8a3e226e --- /dev/null +++ b/samples/tests/toplevel/interpreter.exp @@ -0,0 +1,7 @@ +Pure Prolog Interpreter. + +Consulting file `interpreter_test.pl'... +?- sibling(mary, george). +Yes. +?- No. +?- \ No newline at end of file diff --git a/samples/tests/toplevel/interpreter.inp b/samples/tests/toplevel/interpreter.inp new file mode 100644 index 000000000..67404b61c --- /dev/null +++ b/samples/tests/toplevel/interpreter.inp @@ -0,0 +1,2 @@ +sibling(mary, george). +sibling(jane, george). diff --git a/samples/tests/toplevel/interpreter_test.pl b/samples/tests/toplevel/interpreter_test.pl new file mode 100644 index 000000000..a624023f0 --- /dev/null +++ b/samples/tests/toplevel/interpreter_test.pl @@ -0,0 +1,16 @@ + +father(john, mary). +father(john, andrew). + +mother(jane, mary). +mother(jane, andrew). +mother(jane, george). + +sibling(X, Y) :- + ( + father(F, X), father(F, Y) + ; + mother(M, X), mother(M, Y) + ). + + diff --git a/samples/tests/toplevel/runtests b/samples/tests/toplevel/runtests new file mode 100755 index 000000000..814c576c2 --- /dev/null +++ b/samples/tests/toplevel/runtests @@ -0,0 +1,47 @@ +#!/bin/sh +# Test whether the code generated by the Mercury compiler +# is producing the expected output. +# Return a status of 0 (true) if everything is all right, and 1 otherwise. + +. Mmake.thisdir + +. $DEPTH/handle_options + +# Run the tests in any subdirectories of this one. If any of these +# fail, we still perform the tests in this directory but return a +# status of 1 regardless of the outcome. + +. $DEPTH/subdir_runtests + +if test "$subdir_failures" = "" +then + subdir_status=0 +else + subdir_status=1 +fi + +# Now run all the tests in this directory. +. $DEPTH/startup + +eval mmake $mmakeopts depend_local || exit 1 +eval mmake -k $mmakeopts check_local +checkstatus=$? + +pwdir=`pwd` +thisdirname=`basename $pwdir` + +cat *.res > .allres +if test ! -s .allres -a "$checkstatus" = 0 +then + echo "the tests in the $thisdirname directory succeeded" + echo "mmakeopts=$mmakeopts" + rm -f .allres + . $DEPTH/shutdown + exit $subdir_status +else + echo "the tests in the $thisdirname directory failed" + echo "mmakeopts=$mmakeopts" + echo "the differences are:" + cat .allres + exit 1 +fi diff --git a/samples/tests/toplevel/sort.exp b/samples/tests/toplevel/sort.exp new file mode 100644 index 000000000..d68dd4031 --- /dev/null +++ b/samples/tests/toplevel/sort.exp @@ -0,0 +1,4 @@ +a +b +c +d diff --git a/samples/tests/toplevel/sort.inp b/samples/tests/toplevel/sort.inp new file mode 100644 index 000000000..e77e34eb6 --- /dev/null +++ b/samples/tests/toplevel/sort.inp @@ -0,0 +1,4 @@ +b +c +a +d diff --git a/samples/tests/toplevel/ultra_sub.arg b/samples/tests/toplevel/ultra_sub.arg new file mode 100644 index 000000000..8e5448cc0 --- /dev/null +++ b/samples/tests/toplevel/ultra_sub.arg @@ -0,0 +1 @@ +Xoo Xay foo bar baz diff --git a/samples/tests/toplevel/ultra_sub.exp b/samples/tests/toplevel/ultra_sub.exp new file mode 100644 index 000000000..5412d63c7 --- /dev/null +++ b/samples/tests/toplevel/ultra_sub.exp @@ -0,0 +1 @@ +fay diff --git a/samples/tests/toplevel/ultra_sub.inp b/samples/tests/toplevel/ultra_sub.inp new file mode 100644 index 000000000..1aeaedbf4 --- /dev/null +++ b/samples/tests/toplevel/ultra_sub.inp @@ -0,0 +1 @@ +foo bar baz