mirror of
https://github.com/Mercury-Language/mercury.git
synced 2026-04-16 01:43:35 +00:00
tests/accumulator/*.m:
tests/analysis_*/*.m:
tests/benchmarks*/*.m:
tests/debugger*/*.{m,exp,inp}:
tests/declarative_debugger*/*.{m,exp,inp}:
tests/dppd*/*.m:
tests/exceptions*/*.m:
tests/general*/*.m:
tests/grade_subdirs*/*.m:
tests/hard_coded*/*.m:
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 debugger tests,
specify the new line numbers in .inp files and expect them in .exp files.
51 lines
1.3 KiB
Mathematica
51 lines
1.3 KiB
Mathematica
%---------------------------------------------------------------------------%
|
|
% vim: ts=4 sw=4 et ft=mercury
|
|
%---------------------------------------------------------------------------%
|
|
% Regression test. Loop invariant hoisting incorrectly treated `unused'
|
|
% arguments in calls like outputs.
|
|
%---------------------------------------------------------------------------%
|
|
|
|
:- module loop_inv_test3.
|
|
:- interface.
|
|
|
|
:- import_module io.
|
|
|
|
:- pred main(io::di, io::uo) is det.
|
|
|
|
%---------------------------------------------------------------------------%
|
|
%---------------------------------------------------------------------------%
|
|
|
|
:- implementation.
|
|
|
|
:- import_module int.
|
|
:- import_module list.
|
|
|
|
%---------------------------------------------------------------------------%
|
|
|
|
main(!IO) :-
|
|
loop(10, 10, [], L),
|
|
io.write(L, !IO),
|
|
io.nl(!IO).
|
|
|
|
:- pred loop(int::in, int::in, list(int)::in, list(int)::out) is det.
|
|
|
|
loop(Factor, N, L0, L) :-
|
|
Value = foo(Factor, N1),
|
|
bar(N, N1),
|
|
( N1 = 0 ->
|
|
L = L0
|
|
;
|
|
L1 = [Factor * Value | L0],
|
|
loop(Factor, N - 1, L1, L)
|
|
).
|
|
|
|
:- func foo(int::in, int::unused) = (int::out) is det.
|
|
:- pragma no_inline(foo/2).
|
|
|
|
foo(F, _) = F.
|
|
|
|
:- pred bar(int::in, int::out) is det.
|
|
:- pragma no_inline(bar/2).
|
|
|
|
bar(N, N).
|