[m-rev.] diff: shift some tests

Julien Fischer jfischer at opturion.com
Thu Apr 14 16:09:50 AEST 2022


Shift some tests.

The tests below are not actually invalid, they cause the compiler to emit only
warnings and properly belong in the warnings directory.

tests/invalid/empty_interface.{m,err_exp}:
tests/invalid/foreign_singleton.{m,err_exp}:
tests/invalid/obsolete_proc_pragma.{m,err_exp}:
      Shift these tests into the warnings directory and use the
      appropriate extension for the expected outputs in that directory

tests/invalid/Mmakefile:
tests/invalid/Mercury.options:
tests/warnings/Mercury.options:
tests/warnings/Mmakefile:
      Conform to the above changes.

Julien.

diff --git a/tests/invalid/Mercury.options b/tests/invalid/Mercury.options
index cee64ae..16d7684 100644
--- a/tests/invalid/Mercury.options
+++ b/tests/invalid/Mercury.options
@@ -25,7 +25,6 @@ MCFLAGS-coerce_infer            = --infer-all
  MCFLAGS-coerce_void             = --halt-at-warn
  MCFLAGS-duplicate_instance_2    = --no-intermodule-optimization
  MCFLAGS-ee_invalid              = --verbose-error-messages
-MCFLAGS-empty_interface         = --halt-at-warn -E
  MCFLAGS-exported_mode           = --infer-all --no-intermodule-optimization
  MCFLAGS-exported_unify          = --no-intermodule-optimization
  MCFLAGS-fe_unmapped_verbose     = --verbose-error-messages
@@ -34,7 +33,6 @@ MCFLAGS-foreign_decl_line_number = --no-errorcheck-only --line-numbers \
  MCFLAGS-foreign_enum_invalid    = --verbose-error-messages
  MCFLAGS-foreign_type_line_number = --no-errorcheck-only --line-numbers \
                                      --compile-only
-MCFLAGS-foreign_singleton       = --halt-at-warn
  MCFLAGS-foreign_type            = --compile-only
  MCFLAGS-foreign_type_2          = --no-intermodule-optimization
  MCFLAGS-foreign_type_visibility = --no-intermodule-optimization
@@ -63,7 +61,6 @@ MCFLAGS-mode_inf                = --infer-all --verbose-error-messages
  MCFLAGS-mpj1                    = --infer-all --verbose-error-messages
  MCFLAGS-multisoln_func          = --infer-types --verbose-error-messages
  MCFLAGS-nonexistent_import      = --no-verbose-make --make nonexistent_import
-MCFLAGS-obsolete_proc_pragma    = --halt-at-warn
  MCFLAGS-overloading             = --no-intermodule-optimization
  MCFLAGS-pragma_c_code_no_det    = --warn-inferred-erroneous
  MCFLAGS-record_syntax_errors    = --verbose-error-messages
diff --git a/tests/invalid/Mmakefile b/tests/invalid/Mmakefile
index 36460db..f16993a 100644
--- a/tests/invalid/Mmakefile
+++ b/tests/invalid/Mmakefile
@@ -144,7 +144,6 @@ SINGLEMODULE_PROGS = \
  	det_errors \
  	det_errors_cc \
  	ee_invalid \
-	empty_interface \
  	erroneous_throw_promise \
  	error_in_list \
  	exist_foreign_error \
@@ -158,7 +157,6 @@ SINGLEMODULE_PROGS = \
  	foreign_enum_invalid \
  	foreign_procs_exist_type \
  	foreign_purity_mismatch \
-	foreign_singleton \
  	foreign_solver_type \
  	foreign_type_2 \
  	foreign_type_visibility \
@@ -229,7 +227,6 @@ SINGLEMODULE_PROGS = \
  	not_a_switch \
  	not_in_interface \
  	nullary_ho_func_error \
-	obsolete_proc_pragma \
  	oisu_check_add_pragma_errors \
  	oisu_check_semantic_errors \
  	one_member \
diff --git a/tests/invalid/empty_interface.err_exp b/tests/invalid/empty_interface.err_exp
deleted file mode 100644
index d8ba688..0000000
--- a/tests/invalid/empty_interface.err_exp
+++ /dev/null
@@ -1,8 +0,0 @@
-empty_interface.m:005: Warning: the interface of module `empty_interface' does
-empty_interface.m:005:   not export anything.
-empty_interface.m:005:   To be useful, a module should export something. A file
-empty_interface.m:005:   should contain at least one declaration other than
-empty_interface.m:005:   `:- import_module' in its interface section(s). This
-empty_interface.m:005:   would normally be a `:- pred' or `:- func'
-empty_interface.m:005:   declaration, or a `:- type', `:- inst', `:- mode',
-empty_interface.m:005:   `:- typeclass' or `:- instance' definition.
diff --git a/tests/invalid/empty_interface.m b/tests/invalid/empty_interface.m
deleted file mode 100644
index ffa17dd..0000000
--- a/tests/invalid/empty_interface.m
+++ /dev/null
@@ -1,7 +0,0 @@
-%---------------------------------------------------------------------------%
-% vim: ts=4 sw=4 et ft=mercury
-%---------------------------------------------------------------------------%
-
-:- module empty_interface.
-
-:- interface.
diff --git a/tests/invalid/foreign_singleton.err_exp b/tests/invalid/foreign_singleton.err_exp
deleted file mode 100644
index cebe4df..0000000
--- a/tests/invalid/foreign_singleton.err_exp
+++ /dev/null
@@ -1,12 +0,0 @@
-foreign_singleton.m:025: In the C code for predicate `f'/3:
-foreign_singleton.m:025:   warning: variable `IO0' does not occur in the C
-foreign_singleton.m:025:   code.
-foreign_singleton.m:032: In clause for predicate `f'/3:
-foreign_singleton.m:032:   warning: variable `X' occurs only once in this
-foreign_singleton.m:032:   scope.
-foreign_singleton.m:036: In clause for predicate `g'/3:
-foreign_singleton.m:036:   warning: variable `X' occurs only once in this
-foreign_singleton.m:036:   scope.
-foreign_singleton.m:038: In the C code for predicate `g'/3:
-foreign_singleton.m:038:   warning: variable `IO0' does not occur in the C
-foreign_singleton.m:038:   code.
diff --git a/tests/invalid/foreign_singleton.m b/tests/invalid/foreign_singleton.m
deleted file mode 100644
index 5fc7edf..0000000
--- a/tests/invalid/foreign_singleton.m
+++ /dev/null
@@ -1,43 +0,0 @@
-%---------------------------------------------------------------------------%
-% vim: ts=4 sw=4 et ft=mercury
-%---------------------------------------------------------------------------%
-
-:- module foreign_singleton.
-
-:- interface.
-
-:- import_module io.
-
-:- pred main(io::di, io::uo) is det.
-
-:- implementation.
-
-main(!IO) :-
-    f(X, !IO),
-    io.write_int(X, !IO),
-    io.nl(!IO),
-    g(Y, !IO),
-    io.write_int(Y, !IO),
-    io.nl(!IO).
-
-:- pred f(int::out, io::di, io::uo) is det.
-
-:- pragma foreign_proc("C",
-    f(X::out, IO0::di, _IO::uo),
-    [will_not_call_mercury, promise_pure],
-"
-    X = 5;
-").
-
-f(X, !IO).
-
-:- pred g(int::out, io::di, io::uo) is det.
-
-g(X, !IO).
-
-:- pragma foreign_proc("C",
-    g(X::out, IO0::di, _IO::uo),
-    [will_not_call_mercury, promise_pure],
-"
-    X = 5;
-").
diff --git a/tests/invalid/obsolete_proc_pragma.err_exp b/tests/invalid/obsolete_proc_pragma.err_exp
deleted file mode 100644
index d7f86f4..0000000
--- a/tests/invalid/obsolete_proc_pragma.err_exp
+++ /dev/null
@@ -1,7 +0,0 @@
-obsolete_proc_pragma.m:024: Warning: call to obsolete
-obsolete_proc_pragma.m:024:   `obsolete_proc_pragma.bool_vs_int'(in, out).
-obsolete_proc_pragma.m:024:   The suggested replacement is `xyzzy'/2.
-obsolete_proc_pragma.m:037: Warning: call to obsolete
-obsolete_proc_pragma.m:037:   `obsolete_proc_pragma.bool_vs_int_func'(out) =
-obsolete_proc_pragma.m:037:   in.
-obsolete_proc_pragma.m:037:   The suggested replacement is `xyzzy_func'/1.
diff --git a/tests/invalid/obsolete_proc_pragma.m b/tests/invalid/obsolete_proc_pragma.m
deleted file mode 100644
index 7374fc6..0000000
--- a/tests/invalid/obsolete_proc_pragma.m
+++ /dev/null
@@ -1,61 +0,0 @@
-%---------------------------------------------------------------------------%
-% vim: ts=4 sw=4 et ft=mercury
-%---------------------------------------------------------------------------%
-%
-% Test whether obsolete_proc pragma declarations work correctly.
-%
-%---------------------------------------------------------------------------%
-
-:- module obsolete_proc_pragma.
-:- interface.
-:- import_module io.
-
-:- pred main(io::di, io::uo) is det.
-
-%---------------------------------------------------------------------------%
-
-:- implementation.
-:- import_module bool.
-:- import_module list.
-:- import_module string.
-
-main(!IO) :-
-    % This call SHOULD get an obsolete warning.
-    bool_vs_int(no, PredX),
-    io.format("%d\n", [i(PredX)], !IO),
-    % This call SHOULD NOT get an obsolete warning.
-    ( if bool_vs_int(PredY, 42) then
-        io.write_line(PredY, !IO)
-    else
-        io.write_string("pred failed\n", !IO)
-    ),
-
-    % This call SHOULD NOT get an obsolete warning.
-    bool_vs_int_func(no) = FuncX,
-    io.format("%d\n", [i(FuncX)], !IO),
-    % This call SHOULD get an obsolete warning.
-    ( if bool_vs_int_func(FuncY) = 42 then
-        io.write_line(FuncY, !IO)
-    else
-        io.write_string("func failed\n", !IO)
-    ).
-
-:- pred bool_vs_int(bool, int).
-:- mode bool_vs_int(in, out) is det.
-:- mode bool_vs_int(out, in) is semidet.
-
-:- pragma obsolete_proc(bool_vs_int(in, out), [xyzzy/2]).
-
-bool_vs_int(no, 0).
-bool_vs_int(yes, 1).
-
-:- func bool_vs_int_func(bool) = int.
-:- mode bool_vs_int_func(in) = out is det.
-:- mode bool_vs_int_func(out) = in is semidet.
-
-:- pragma obsolete_proc(bool_vs_int_func(out) = in, [xyzzy_func/1]).
-
-bool_vs_int_func(no) = 0.
-bool_vs_int_func(yes) = 1.
-
-%---------------------------------------------------------------------------%
diff --git a/tests/warnings/Mercury.options b/tests/warnings/Mercury.options
index adba7e8..22ac25d 100644
--- a/tests/warnings/Mercury.options
+++ b/tests/warnings/Mercury.options
@@ -16,6 +16,9 @@ MCFLAGS-arg_order_rearrangment	= \
  MCFLAGS-bug412			= --warn-unused-imports
  MCFLAGS-duplicate_call		= --warn-duplicate-calls
  MCFLAGS-duplicate_const		= --warn-duplicate-calls
+
+MCFLAGS-empty_interface		= -E
+
  MCFLAGS-unused_args_analysis    = \
  				--intermodule-analysis \
  				--optimize-unused-args \
diff --git a/tests/warnings/Mmakefile b/tests/warnings/Mmakefile
index 3ba39b6..d1d6a01 100644
--- a/tests/warnings/Mmakefile
+++ b/tests/warnings/Mmakefile
@@ -28,6 +28,8 @@ ERRORCHECK_PROGS = \
  	double_underscore \
  	duplicate_call \
  	duplicate_const \
+	empty_interface \
+	foreign_singleton \
  	gh85 \
  	inconsistent_pred_order \
  	inf_recursion_lambda \
@@ -37,6 +39,7 @@ ERRORCHECK_PROGS = \
  	missing_if \
  	non_contiguous_decls \
  	non_stratification \
+	obsolete_proc_pragma \
  	occurs \
  	pragma_source_file \
  	purity_warnings \
diff --git a/tests/warnings/empty_interface.exp b/tests/warnings/empty_interface.exp
new file mode 100644
index 0000000..d8ba688
--- /dev/null
+++ b/tests/warnings/empty_interface.exp
@@ -0,0 +1,8 @@
+empty_interface.m:005: Warning: the interface of module `empty_interface' does
+empty_interface.m:005:   not export anything.
+empty_interface.m:005:   To be useful, a module should export something. A file
+empty_interface.m:005:   should contain at least one declaration other than
+empty_interface.m:005:   `:- import_module' in its interface section(s). This
+empty_interface.m:005:   would normally be a `:- pred' or `:- func'
+empty_interface.m:005:   declaration, or a `:- type', `:- inst', `:- mode',
+empty_interface.m:005:   `:- typeclass' or `:- instance' definition.
diff --git a/tests/warnings/empty_interface.m b/tests/warnings/empty_interface.m
new file mode 100644
index 0000000..ffa17dd
--- /dev/null
+++ b/tests/warnings/empty_interface.m
@@ -0,0 +1,7 @@
+%---------------------------------------------------------------------------%
+% vim: ts=4 sw=4 et ft=mercury
+%---------------------------------------------------------------------------%
+
+:- module empty_interface.
+
+:- interface.
diff --git a/tests/warnings/foreign_singleton.exp b/tests/warnings/foreign_singleton.exp
new file mode 100644
index 0000000..cebe4df
--- /dev/null
+++ b/tests/warnings/foreign_singleton.exp
@@ -0,0 +1,12 @@
+foreign_singleton.m:025: In the C code for predicate `f'/3:
+foreign_singleton.m:025:   warning: variable `IO0' does not occur in the C
+foreign_singleton.m:025:   code.
+foreign_singleton.m:032: In clause for predicate `f'/3:
+foreign_singleton.m:032:   warning: variable `X' occurs only once in this
+foreign_singleton.m:032:   scope.
+foreign_singleton.m:036: In clause for predicate `g'/3:
+foreign_singleton.m:036:   warning: variable `X' occurs only once in this
+foreign_singleton.m:036:   scope.
+foreign_singleton.m:038: In the C code for predicate `g'/3:
+foreign_singleton.m:038:   warning: variable `IO0' does not occur in the C
+foreign_singleton.m:038:   code.
diff --git a/tests/warnings/foreign_singleton.m b/tests/warnings/foreign_singleton.m
new file mode 100644
index 0000000..5fc7edf
--- /dev/null
+++ b/tests/warnings/foreign_singleton.m
@@ -0,0 +1,43 @@
+%---------------------------------------------------------------------------%
+% vim: ts=4 sw=4 et ft=mercury
+%---------------------------------------------------------------------------%
+
+:- module foreign_singleton.
+
+:- interface.
+
+:- import_module io.
+
+:- pred main(io::di, io::uo) is det.
+
+:- implementation.
+
+main(!IO) :-
+    f(X, !IO),
+    io.write_int(X, !IO),
+    io.nl(!IO),
+    g(Y, !IO),
+    io.write_int(Y, !IO),
+    io.nl(!IO).
+
+:- pred f(int::out, io::di, io::uo) is det.
+
+:- pragma foreign_proc("C",
+    f(X::out, IO0::di, _IO::uo),
+    [will_not_call_mercury, promise_pure],
+"
+    X = 5;
+").
+
+f(X, !IO).
+
+:- pred g(int::out, io::di, io::uo) is det.
+
+g(X, !IO).
+
+:- pragma foreign_proc("C",
+    g(X::out, IO0::di, _IO::uo),
+    [will_not_call_mercury, promise_pure],
+"
+    X = 5;
+").
diff --git a/tests/warnings/obsolete_proc_pragma.exp b/tests/warnings/obsolete_proc_pragma.exp
new file mode 100644
index 0000000..d7f86f4
--- /dev/null
+++ b/tests/warnings/obsolete_proc_pragma.exp
@@ -0,0 +1,7 @@
+obsolete_proc_pragma.m:024: Warning: call to obsolete
+obsolete_proc_pragma.m:024:   `obsolete_proc_pragma.bool_vs_int'(in, out).
+obsolete_proc_pragma.m:024:   The suggested replacement is `xyzzy'/2.
+obsolete_proc_pragma.m:037: Warning: call to obsolete
+obsolete_proc_pragma.m:037:   `obsolete_proc_pragma.bool_vs_int_func'(out) =
+obsolete_proc_pragma.m:037:   in.
+obsolete_proc_pragma.m:037:   The suggested replacement is `xyzzy_func'/1.
diff --git a/tests/warnings/obsolete_proc_pragma.m b/tests/warnings/obsolete_proc_pragma.m
new file mode 100644
index 0000000..7374fc6
--- /dev/null
+++ b/tests/warnings/obsolete_proc_pragma.m
@@ -0,0 +1,61 @@
+%---------------------------------------------------------------------------%
+% vim: ts=4 sw=4 et ft=mercury
+%---------------------------------------------------------------------------%
+%
+% Test whether obsolete_proc pragma declarations work correctly.
+%
+%---------------------------------------------------------------------------%
+
+:- module obsolete_proc_pragma.
+:- interface.
+:- import_module io.
+
+:- pred main(io::di, io::uo) is det.
+
+%---------------------------------------------------------------------------%
+
+:- implementation.
+:- import_module bool.
+:- import_module list.
+:- import_module string.
+
+main(!IO) :-
+    % This call SHOULD get an obsolete warning.
+    bool_vs_int(no, PredX),
+    io.format("%d\n", [i(PredX)], !IO),
+    % This call SHOULD NOT get an obsolete warning.
+    ( if bool_vs_int(PredY, 42) then
+        io.write_line(PredY, !IO)
+    else
+        io.write_string("pred failed\n", !IO)
+    ),
+
+    % This call SHOULD NOT get an obsolete warning.
+    bool_vs_int_func(no) = FuncX,
+    io.format("%d\n", [i(FuncX)], !IO),
+    % This call SHOULD get an obsolete warning.
+    ( if bool_vs_int_func(FuncY) = 42 then
+        io.write_line(FuncY, !IO)
+    else
+        io.write_string("func failed\n", !IO)
+    ).
+
+:- pred bool_vs_int(bool, int).
+:- mode bool_vs_int(in, out) is det.
+:- mode bool_vs_int(out, in) is semidet.
+
+:- pragma obsolete_proc(bool_vs_int(in, out), [xyzzy/2]).
+
+bool_vs_int(no, 0).
+bool_vs_int(yes, 1).
+
+:- func bool_vs_int_func(bool) = int.
+:- mode bool_vs_int_func(in) = out is det.
+:- mode bool_vs_int_func(out) = in is semidet.
+
+:- pragma obsolete_proc(bool_vs_int_func(out) = in, [xyzzy_func/1]).
+
+bool_vs_int_func(no) = 0.
+bool_vs_int_func(yes) = 1.
+
+%---------------------------------------------------------------------------%


More information about the reviews mailing list