mirror of
https://github.com/Mercury-Language/mercury.git
synced 2026-04-18 02:43:40 +00:00
tests/invalid/*.{m,err_exp}:
tests/misc_tests/*.m:
tests/mmc_make/*.m:
tests/par_conj/*.m:
tests/purity/*.m:
tests/stm/*.m:
tests/string_format/*.m:
tests/structure_reuse/*.m:
tests/submodules/*.m:
tests/tabling/*.m:
tests/term/*.m:
tests/trailing/*.m:
tests/typeclasses/*.m:
tests/valid/*.m:
tests/warnings/*.{m,exp}:
Make these tests use four-space indentation, and ensure that
each module is imported on its own line. (I intend to use the latter
to figure out which subdirectories' tests can be executed in parallel.)
These changes usually move code to different lines. For the tests
that check compiler error messages, expect the new line numbers.
browser/cterm.m:
browser/tree234_cc.m:
Import only one module per line.
tests/hard_coded/boyer.m:
Fix something I missed.
62 lines
1.7 KiB
Mathematica
62 lines
1.7 KiB
Mathematica
%---------------------------------------------------------------------------%
|
|
% vim: ts=4 sw=4 et ft=mercury
|
|
%---------------------------------------------------------------------------%
|
|
%
|
|
% Test error messages with problems that arise trying to taking the address
|
|
% of multi-moded predicates.
|
|
|
|
:- module multimode_addr_problems.
|
|
:- interface.
|
|
|
|
:- import_module io.
|
|
|
|
:- pred main(io::di, io::uo) is cc_multi.
|
|
|
|
%---------------------------------------------------------------------------%
|
|
%---------------------------------------------------------------------------%
|
|
|
|
:- implementation.
|
|
|
|
:- import_module int.
|
|
:- import_module list.
|
|
|
|
%---------------------------------------------------------------------------%
|
|
|
|
main(!IO) :-
|
|
% The compiler can't choose which mode of absolute to use.
|
|
Abs = absolute,
|
|
Abs(3, X),
|
|
io.write_int(X, !IO),
|
|
io.nl(!IO).
|
|
|
|
:- pred absolute(int, int).
|
|
:- mode absolute(in, out) is det.
|
|
:- mode absolute(out, in) is multi.
|
|
|
|
:- pragma promise_equivalent_clauses(absolute/2).
|
|
|
|
absolute(X::in, Y::out) :-
|
|
Y = ( X < 0 -> -X ; X).
|
|
|
|
absolute(X::out, Y::in) :-
|
|
( X = Y
|
|
; X = -Y
|
|
).
|
|
|
|
:- func my_foldl(func(L, A) = A, list(L), A) = A.
|
|
:- mode my_foldl(in(func(in, in) = out is det), in, in) = out is det.
|
|
|
|
my_foldl(F, L, A0) = A :-
|
|
% None of the modes of f2p are usable.
|
|
% XXX the error message without this explicit unification is confusing.
|
|
P = f2p(F),
|
|
list.foldl(P, L, A0, A).
|
|
|
|
:- pred f2p(func(L, A) = A, L, A, A).
|
|
:- mode f2p(in(func(in, di) = uo is det), in, di, uo) is det.
|
|
% :- mode f2p(in(func(in, in) = out is det), in, in, out) is det.
|
|
:- mode f2p(in(func(in, in) = out is semidet), in, in, out) is semidet.
|
|
|
|
f2p(F, L, A0, A) :-
|
|
F(L, A0) = A.
|