mirror of
https://github.com/Mercury-Language/mercury.git
synced 2026-04-16 09:53:36 +00:00
tests/warnings/*.m:
Bring the programming style of these modules up to date,
except where the problem being tested for seems to be related
to the old programming style
In the infinite_recursion test case, add code that we *should*
warn about, but currently don't.
tests/warnings/*.m:
Update the expected outputs to account for the changes in line
numbers, and the fact that the compiler computes the contexts
of (if C then T else E) if-then-elses differently from (C -> T; E)
if-then-else (it takes the context of the "then" vs the context
of the ";").
Delete arg_order_rearrangment.exp2. It was long unused, but
deleting it in CVS would not have allowed us to put it back later.
45 lines
1.4 KiB
Mathematica
45 lines
1.4 KiB
Mathematica
%---------------------------------------------------------------------------%
|
|
% vim: ts=4 sw=4 et ft=mercury
|
|
%---------------------------------------------------------------------------%
|
|
%
|
|
% This test case tests whether we generate warnings such as this:
|
|
%
|
|
% bad_singleton_warning.m:031: In clause for predicate
|
|
% bad_singleton_warning.m:031: `bad_singleton_warning.is_it_there_str'/3:
|
|
% bad_singleton_warning.m:031: warning: variable `Value' occurs only once in
|
|
% bad_singleton_warning.m:031: this scope.
|
|
%
|
|
%---------------------------------------------------------------------------%
|
|
|
|
:- module missing_singleton_warning.
|
|
:- interface.
|
|
|
|
:- import_module map.
|
|
|
|
:- pred is_it_there_test(map(int, string)::in, int::in) is semidet.
|
|
|
|
:- pred is_it_there_str(map(int, string)::in, int::in, string::out) is det.
|
|
|
|
:- implementation.
|
|
|
|
is_it_there_test(Map, Key) :-
|
|
% Test whether we get a warning on an ordinary quantification.
|
|
some [Value] (
|
|
map.search(Map, Key, _Result)
|
|
).
|
|
|
|
is_it_there_str(Map, Key, Str) :-
|
|
% Test whether we get a warning on a special quantification
|
|
% on the condition of an if-then-else. (This is treated separately
|
|
% by the compiler because it quantifies over not a single goal, but
|
|
% over the "conjunction" formed by the condition and the then-part.)
|
|
( if
|
|
some [Value] (
|
|
map.search(Map, Key, _Result)
|
|
)
|
|
then
|
|
Str = "there"
|
|
else
|
|
Str = "not there"
|
|
).
|