[m-rev.] diff: move trailing regression tests from extras to tests
Julien Fischer
juliensf at cs.mu.OZ.AU
Wed Jan 11 15:08:15 AEDT 2006
Estimated hours taken: 1
Branches: main
Move some of the regression tests for trailing from
extras/trailed_update/tests to a new trailing subdirectory in the test suite.
The motivation for doing this is that parts of the trailed_update package are
broken (and likely to remain so until the solver type/purity situation is
resolved) and the tests are not being run. Also, the main test suite is
probably a better place for these anyway.
extras/trailed_update/tests/Mmakefile:
extras/trailed_update/tests/func_trail_test.{m,exp}:
extras/trailed_update/tests/func_trail_test_2.{m,exp}:
Delete these tests from here.
tests/trailing:
New subdirectory that contains regression tests for trailing.
tests/trailing/Mmakefile:
tests/trailing/Mercury.options:
tests/trailing/func_trail_test.{m,exp}:
tests/trailing/func_trail_test_2.{m,exp}:
Move the test cases from extras/trailed_update/tests to here.
Update the syntax in the test cases and escape some special characters
in the C code correctly.
tests/README:
Update this file to mention the trailing directory.
Julien.
Index: extras/trailed_update/tests/Mmakefile
===================================================================
RCS file: /home/mercury1/repository/mercury/extras/trailed_update/tests/Mmakefile,v
retrieving revision 1.10
diff -u -r1.10 Mmakefile
--- extras/trailed_update/tests/Mmakefile 22 Nov 2002 11:50:56 -0000 1.10
+++ extras/trailed_update/tests/Mmakefile 11 Jan 2006 03:53:25 -0000
@@ -35,9 +35,9 @@
# The "var_test" program does not work in ".rt" grades,
# since it uses the "var" module which does not work in ".rt" grades.
ifeq "$(findstring .rt,$(GRADE))" ".rt"
-PROGS = func_trail_test func_trail_test_2
+PROGS =
else
-PROGS = func_trail_test func_trail_test_2 var_test
+PROGS = var_test
endif
DEPENDS = $(PROGS:%=%.depend)
Index: extras/trailed_update/tests/func_trail_test.exp
===================================================================
RCS file: extras/trailed_update/tests/func_trail_test.exp
diff -N extras/trailed_update/tests/func_trail_test.exp
--- extras/trailed_update/tests/func_trail_test.exp 2 Jun 1998 05:32:17 -0000 1.1
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,46 +0,0 @@
-before: 1 0
->> enter (1)
-inside: 1 1
-<< leave (1)
-after: 1 1
-=> fail back inside: 1
-inside: 1 2
-<< leave (1)
-after: 1 2
-=> fail back inside: 1
-inside: 1 3
-<< leave (1)
-after: 1 3
-=> fail back inside: 1
-<= fail back outside: 1
-before: 2 0
->> enter (2)
-inside: 2 1
-<< leave (2)
-after: 2 1
-=> fail back inside: 2
-inside: 2 2
-<< leave (2)
-after: 2 2
-=> fail back inside: 2
-inside: 2 3
-<< leave (2)
-after: 2 3
-=> fail back inside: 2
-<= fail back outside: 2
-before: 3 0
->> enter (3)
-inside: 3 1
-<< leave (3)
-after: 3 1
-=> fail back inside: 3
-inside: 3 2
-<< leave (3)
-after: 3 2
-=> fail back inside: 3
-inside: 3 3
-<< leave (3)
-after: 3 3
-=> fail back inside: 3
-<= fail back outside: 3
-Failure
Index: extras/trailed_update/tests/func_trail_test.m
===================================================================
RCS file: extras/trailed_update/tests/func_trail_test.m
diff -N extras/trailed_update/tests/func_trail_test.m
--- extras/trailed_update/tests/func_trail_test.m 8 Oct 1999 02:56:04 -0000 1.3
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,110 +0,0 @@
-:- module func_trail_test.
-:- interface.
-:- import_module io.
-
-:- impure pred main(io__state::di, io__state::uo) is det.
-
-:- implementation.
-
-:- import_module int.
-
-main -->
- ( { impure trail_test } ->
- io__write_string("Success\n")
- ;
- io__write_string("Failure\n")
- ).
-
-
-:- impure pred trail_test is failure.
-
-trail_test :-
- small_int(I),
- impure trail_test_message("before", I, 0),
- impure enter(I),
- small_int(J),
- impure trail_test_message("inside", I, J),
- impure leave(I),
- impure trail_test_message("after", I, J),
- fail.
-
-
-:- pred small_int(int::out) is multi.
-
-small_int(1).
-small_int(2).
-small_int(3).
-
-:- impure pred trail_test_message(string::in, int::in, int::in) is det.
-
-:- impure pred enter(int::in) is det.
-:- impure pred leave(int::in) is det.
-
-:- pragma c_header_code("
-#include <stdio.h>
-").
-
-:- pragma c_code(trail_test_message(Prefix::in, I::in, J::in),
- will_not_call_mercury, "
- printf(""%s: %d %d\n"",
- (char *)Prefix, (int)I, (int)J);
-").
-
-
-:- pragma c_header_code("
-#include <mercury_trail.h>
-
-
-void enter_failing(int handle, MR_untrail_reason reason);
-void leave_failing(int handle, MR_untrail_reason reason);
-
-
-#include <stdio.h>
-
-
-void enter_failing(int handle, MR_untrail_reason reason) {
- switch (reason) {
- case MR_exception:
- case MR_undo:
- case MR_retry:
-/* printf(""enter_failing: exception/undo/retry\n""); */
- printf(""=> fail back inside: %d\n"", handle);
- break;
- default:
- printf(""enter_failing: default\n"");
- break;
- }
-}
-
-
-void leave_failing(int handle, MR_untrail_reason reason) {
- switch (reason) {
- case MR_exception:
- case MR_undo:
- case MR_retry:
-/* printf(""leave_failing: exception/undo/retry\n""); */
- printf(""<= fail back outside: %d\n"", handle);
- break;
- case MR_commit:
- case MR_solve:
- printf(""leave_failing: commit/solve\n"");
- break;
- default:
- printf(""leave_failing: default\n"");
- /* we may need to do something if reason == MR_gc */
- break;
- }
-}
-
-").
-
-:- pragma c_code(enter(I::in), will_not_call_mercury, "
- printf("">> enter (%d)\n"", (int) I);
- MR_trail_function(leave_failing, (void *) I);
-").
-
-
-:- pragma c_code(leave(I::in), will_not_call_mercury, "
- printf(""<< leave (%d)\n"", (int) I);
- MR_trail_function(enter_failing, (void *) I);
-").
Index: extras/trailed_update/tests/func_trail_test_2.exp
===================================================================
RCS file: extras/trailed_update/tests/func_trail_test_2.exp
diff -N extras/trailed_update/tests/func_trail_test_2.exp
--- extras/trailed_update/tests/func_trail_test_2.exp 2 Jun 1998 05:32:22 -0000 1.1
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,10 +0,0 @@
-before: 1 0
->> enter (1)
-<= fail: 1
-before: 2 0
->> enter (2)
-<= fail: 2
-before: 3 0
->> enter (3)
-<= fail: 3
-Failure
Index: extras/trailed_update/tests/func_trail_test_2.m
===================================================================
RCS file: extras/trailed_update/tests/func_trail_test_2.m
diff -N extras/trailed_update/tests/func_trail_test_2.m
--- extras/trailed_update/tests/func_trail_test_2.m 15 Nov 2002 03:31:56 -0000 1.4
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,117 +0,0 @@
-:- module func_trail_test_2.
-:- interface.
-:- import_module io.
-
-:- impure pred main(io__state::di, io__state::uo) is det.
-
-:- implementation.
-
-:- import_module int.
-
-main -->
- ( { impure trail_test } ->
- io__write_string("Success\n")
- ;
- io__write_string("Failure\n")
- ).
-
-
-:- impure pred trail_test is failure.
-
-trail_test :-
- small_int(I),
- impure trail_test_message("before", I, 0),
- impure enter(I),
- small_int_2(J),
- small_int(J),
- impure trail_test_message("inside", I, J),
- impure leave(I),
- impure trail_test_message("after", I, J),
- fail.
-
-
-:- pred small_int(int::out) is multi.
-
-small_int(1).
-small_int(2).
-small_int(3).
-
-:- pred small_int_2(int::out) is multi.
-
-small_int_2(4).
-small_int_2(5).
-small_int_2(6).
-
-:- impure pred trail_test_message(string::in, int::in, int::in) is det.
-
-:- impure pred enter(int::in) is det.
-:- impure pred leave(int::in) is det.
-
-:- pragma c_header_code("
-#include <stdio.h>
-").
-
-:- pragma c_code(trail_test_message(Prefix::in, I::in, J::in),
- will_not_call_mercury, "
- printf(""%s: %d %d\\n"",
- (char *)Prefix, (int)I, (int)J);
-").
-
-
-:- pragma c_header_code("
-#include ""mercury_trail.h""
-
-
-void trace_redo(int handle, MR_untrail_reason reason);
-void trace_fail(int handle, MR_untrail_reason reason);
-
-
-#include <stdio.h>
-
-
-void trace_fail(int handle, MR_untrail_reason reason) {
- switch (reason) {
- case MR_exception:
- case MR_undo:
- case MR_retry:
-/* printf(""trace_fail: exception/undo/retry\\n""); */
- printf(""<= fail: %d\\n"", handle);
- break;
- default:
- printf(""trace_fail: default\\n"");
- break;
- }
-}
-
-
-void trace_redo(int handle, MR_untrail_reason reason) {
- switch (reason) {
- case MR_exception:
- case MR_undo:
- case MR_retry:
-/* printf(""trace_redo: exception/undo/retry\\n""); */
- printf("">= redo: %d\\n"", handle);
- break;
- case MR_commit:
- case MR_solve:
- printf(""trace_redo: commit/solve\\n"");
- break;
- default:
- printf(""trace_redo: default\\n"");
- /* we may need to do something if reason == MR_gc */
- break;
- }
-}
-
-").
-
-:- pragma c_code(enter(I::in), will_not_call_mercury, "
- printf("">> enter (%d)\\n"", (int) I);
- MR_trail_function(trace_fail, (void *) I);
-").
-
-
-:- pragma c_code(leave(I::in), will_not_call_mercury, "
- printf(""<< leave (%d)\\n"", (int) I);
- MR_trail_function(trace_redo, (void *) I);
-").
Index: tests/README
===================================================================
RCS file: /home/mercury1/repository/tests/README,v
retrieving revision 1.8
diff -u -r1.8 README
--- tests/README 16 Oct 2004 15:08:55 -0000 1.8
+++ tests/README 11 Jan 2006 04:01:43 -0000
@@ -71,4 +71,9 @@
This directory tests the compiler's termination analyser. These
tests work by comparing the contents of the .trans_opt file emitted
by the compiler with the hand-written `.trans_opt_exp' file.
- This directory is also used for testing the compiler's exception analysis.
+ This directory is also used for testing the compiler's exception
+ analysis.
+
+trailing
+ This directory contains tests that make use of the trail.
+ These tests are only run in trailing grades.
Index: tests/trailing/Mercury.options
===================================================================
RCS file: tests/trailing/Mercury.options
diff -N tests/trailing/Mercury.options
Index: tests/trailing/Mmakefile
===================================================================
RCS file: tests/trailing/Mmakefile
diff -N tests/trailing/Mmakefile
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ tests/trailing/Mmakefile 11 Jan 2006 03:49:28 -0000
@@ -0,0 +1,26 @@
+#-----------------------------------------------------------------------------#
+
+THIS_DIR = trailing
+
+#-----------------------------------------------------------------------------#
+
+ifneq "$(filter tr%,$(GRADE))" ""
+ TRAIL_PROGS =
+else
+ TRAIL_PROGS = \
+ func_trail_test \
+ func_trail_test_2
+endif
+
+#-----------------------------------------------------------------------------#
+
+TESTS = $(TRAIL_PROGS)
+SUBDIRS =
+TESTS_DIR=..
+include $(TESTS_DIR)/Mmake.common
+
+# Module-specific options should go in Mercury.options so they
+# can be found by `mmc --make'.
+include Mercury.options
+
+%.runtest: %.res ;
Index: tests/trailing/func_trail_test.exp
===================================================================
RCS file: tests/trailing/func_trail_test.exp
diff -N tests/trailing/func_trail_test.exp
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ tests/trailing/func_trail_test.exp 11 Jan 2006 03:17:31 -0000
@@ -0,0 +1,46 @@
+before: 1 0
+>> enter (1)
+inside: 1 1
+<< leave (1)
+after: 1 1
+=> fail back inside: 1
+inside: 1 2
+<< leave (1)
+after: 1 2
+=> fail back inside: 1
+inside: 1 3
+<< leave (1)
+after: 1 3
+=> fail back inside: 1
+<= fail back outside: 1
+before: 2 0
+>> enter (2)
+inside: 2 1
+<< leave (2)
+after: 2 1
+=> fail back inside: 2
+inside: 2 2
+<< leave (2)
+after: 2 2
+=> fail back inside: 2
+inside: 2 3
+<< leave (2)
+after: 2 3
+=> fail back inside: 2
+<= fail back outside: 2
+before: 3 0
+>> enter (3)
+inside: 3 1
+<< leave (3)
+after: 3 1
+=> fail back inside: 3
+inside: 3 2
+<< leave (3)
+after: 3 2
+=> fail back inside: 3
+inside: 3 3
+<< leave (3)
+after: 3 3
+=> fail back inside: 3
+<= fail back outside: 3
+Failure
Index: tests/trailing/func_trail_test.m
===================================================================
RCS file: tests/trailing/func_trail_test.m
diff -N tests/trailing/func_trail_test.m
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ tests/trailing/func_trail_test.m 11 Jan 2006 03:32:32 -0000
@@ -0,0 +1,109 @@
+:- module func_trail_test.
+:- interface.
+:- import_module io.
+
+:- pred main(io::di, io::uo) is det.
+
+:- implementation.
+
+:- import_module int.
+
+:- pragma promise_pure(main/2).
+main(!IO) :-
+ ( impure trail_test ->
+ io.write_string("Success\n", !IO)
+ ;
+ io.write_string("Failure\n", !IO)
+ ).
+
+:- impure pred trail_test is failure.
+
+trail_test :-
+ small_int(I),
+ impure trail_test_message("before", I, 0),
+ impure enter(I),
+ small_int(J),
+ impure trail_test_message("inside", I, J),
+ impure leave(I),
+ impure trail_test_message("after", I, J),
+ fail.
+
+:- pred small_int(int::out) is multi.
+
+small_int(1).
+small_int(2).
+small_int(3).
+
+:- impure pred trail_test_message(string::in, int::in, int::in) is det.
+
+:- impure pred enter(int::in) is det.
+:- impure pred leave(int::in) is det.
+
+:- pragma foreign_decl("C",
+"
+ #include <stdio.h>
+ #include ""mercury_trail.h""
+
+ void enter_failing(int handle, MR_untrail_reason reason);
+ void leave_failing(int handle, MR_untrail_reason reason);
+").
+
+:- pragma foreign_proc("C",
+ trail_test_message(Prefix::in, I::in, J::in),
+ [will_not_call_mercury, will_not_modify_trail],
+"
+printf(\"%s: %d %d\\n\", (char *)Prefix, (int)I, (int)J);
+").
+
+:- pragma foreign_code("C", "
+
+void enter_failing(int handle, MR_untrail_reason reason) {
+ switch (reason) {
+ case MR_exception:
+ case MR_undo:
+ case MR_retry:
+/* printf(""enter_failing: exception/undo/retry\n""); */
+ printf(\"=> fail back inside: %d\\n\", handle);
+ break;
+ default:
+ printf(\"enter_failing: default\\n\");
+ break;
+ }
+}
+
+void leave_failing(int handle, MR_untrail_reason reason) {
+ switch (reason) {
+ case MR_exception:
+ case MR_undo:
+ case MR_retry:
+/* printf(""leave_failing: exception/undo/retry\n""); */
+ printf(\"<= fail back outside: %d\\n\", handle);
+ break;
+ case MR_commit:
+ case MR_solve:
+ printf(\"leave_failing: commit/solve\\n\");
+ break;
+ default:
+ printf(\"leave_failing: default\\n\");
+ /* we may need to do something if reason == MR_gc */
+ break;
+ }
+}
+").
+
+:- pragma foreign_proc("C",
+ enter(I::in),
+ [will_not_call_mercury, may_modify_trail],
+"
+ printf(\">> enter (%d)\\n\", (int) I);
+ MR_trail_function(leave_failing, (void *) I);
+").
+
+
+:- pragma foreign_proc("C",
+ leave(I::in),
+ [will_not_call_mercury, may_modify_trail],
+"
+ printf(\"<< leave (%d)\\n\", (int) I);
+ MR_trail_function(enter_failing, (void *) I);
+").
Index: tests/trailing/func_trail_test_2.exp
===================================================================
RCS file: tests/trailing/func_trail_test_2.exp
diff -N tests/trailing/func_trail_test_2.exp
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ tests/trailing/func_trail_test_2.exp 11 Jan 2006 03:34:03 -0000
@@ -0,0 +1,10 @@
+before: 1 0
+>> enter (1)
+<= fail: 1
+before: 2 0
+>> enter (2)
+<= fail: 2
+before: 3 0
+>> enter (3)
+<= fail: 3
+Failure
Index: tests/trailing/func_trail_test_2.m
===================================================================
RCS file: tests/trailing/func_trail_test_2.m
diff -N tests/trailing/func_trail_test_2.m
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ tests/trailing/func_trail_test_2.m 11 Jan 2006 03:44:11 -0000
@@ -0,0 +1,115 @@
+:- module func_trail_test_2.
+:- interface.
+:- import_module io.
+
+:- pred main(io::di, io::uo) is det.
+
+:- implementation.
+
+:- import_module int.
+
+:- pragma promise_pure(main/2).
+main(!IO) :-
+ ( impure trail_test ->
+ io.write_string("Success\n", !IO)
+ ;
+ io.write_string("Failure\n", !IO)
+ ).
+
+:- impure pred trail_test is failure.
+
+trail_test :-
+ small_int(I),
+ impure trail_test_message("before", I, 0),
+ impure enter(I),
+ small_int_2(J),
+ small_int(J),
+ impure trail_test_message("inside", I, J),
+ impure leave(I),
+ impure trail_test_message("after", I, J),
+ fail.
+
+:- pred small_int(int::out) is multi.
+
+small_int(1).
+small_int(2).
+small_int(3).
+
+:- pred small_int_2(int::out) is multi.
+
+small_int_2(4).
+small_int_2(5).
+small_int_2(6).
+
+:- impure pred trail_test_message(string::in, int::in, int::in) is det.
+
+:- impure pred enter(int::in) is det.
+:- impure pred leave(int::in) is det.
+
+:- pragma foreign_decl("C","
+
+ #include <stdio.h>
+ #include \"mercury_trail.h\"
+
+ void trace_redo(int handle, MR_untrail_reason reason);
+ void trace_fail(int handle, MR_untrail_reason reason);
+").
+
+:- pragma foreign_proc("C",
+ trail_test_message(Prefix::in, I::in, J::in),
+ [will_not_call_mercury, will_not_modify_trail],
+"
+ printf(""%s: %d %d\\n"", (char *)Prefix, (int)I, (int)J);
+").
+
+:- pragma foreign_code("C", "
+
+void trace_fail(int handle, MR_untrail_reason reason) {
+ switch (reason) {
+ case MR_exception:
+ case MR_undo:
+ case MR_retry:
+/* printf(""trace_fail: exception/undo/retry\\n""); */
+ printf(\"<= fail: %d\\n\", handle);
+ break;
+ default:
+ printf(\"trace_fail: default\\n\");
+ break;
+ }
+}
+
+void trace_redo(int handle, MR_untrail_reason reason) {
+ switch (reason) {
+ case MR_exception:
+ case MR_undo:
+ case MR_retry:
+/* printf(""trace_redo: exception/undo/retry\\n""); */
+ printf(\">= redo: %d\\n\", handle);
+ break;
+ case MR_commit:
+ case MR_solve:
+ printf(\"trace_redo: commit/solve\\n\");
+ break;
+ default:
+ printf(\"trace_redo: default\\n\");
+ /* we may need to do something if reason == MR_gc */
+ break;
+ }
+}
+").
+
+:- pragma foreign_proc("C",
+ enter(I::in),
+ [will_not_call_mercury],
+"
+ printf(\">> enter (%d)\\n\", (int) I);
+ MR_trail_function(trace_fail, (void *) I);
+").
+
+:- pragma foreign_proc("C",
+ leave(I::in),
+ [will_not_call_mercury],
+"
+ printf(\"<< leave (%d)\\n\", (int) I);
+ MR_trail_function(trace_redo, (void *) I);
+").
--------------------------------------------------------------------------
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