mirror of
https://github.com/Mercury-Language/mercury.git
synced 2026-04-19 11:23:46 +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.
52 lines
1.1 KiB
Mathematica
52 lines
1.1 KiB
Mathematica
%---------------------------------------------------------------------------%
|
|
% vim: ts=4 sw=4 et ft=mercury
|
|
%---------------------------------------------------------------------------%
|
|
|
|
:- module if_then_else_expr_state_var.
|
|
|
|
:- interface.
|
|
|
|
:- import_module io.
|
|
|
|
:- pred main(io::di, io::uo) is det.
|
|
|
|
:- implementation.
|
|
|
|
:- import_module int.
|
|
:- import_module list.
|
|
:- import_module string.
|
|
|
|
main(!IO) :-
|
|
test(1, 101, !IO),
|
|
test(2, 102, !IO),
|
|
test(11, 111, !IO),
|
|
test(12, 112, !IO).
|
|
|
|
:- pred test(int::in, int::in, io::di, io::uo) is det.
|
|
|
|
test(InitX, InitY, !IO) :-
|
|
some [!X, !Y] (
|
|
!:X = InitX,
|
|
!:Y = InitY,
|
|
set( ( if big(!.X) then increment3(!.Y, !:Y) else !.X + 5 ), !:X),
|
|
FinalX = !.X,
|
|
FinalY = !.Y
|
|
),
|
|
io.format("InitX = %3d, FinalX = %3d\n", [i(InitX), i(FinalX)], !IO),
|
|
io.format("InitY = %3d, FinalY = %3d\n", [i(InitY), i(FinalY)], !IO),
|
|
io.nl(!IO).
|
|
|
|
:- pred big(int::in) is semidet.
|
|
|
|
big(N) :-
|
|
N > 10.
|
|
|
|
:- func increment3(int::in, int::out) = (int::out) is det.
|
|
|
|
increment3(N, M) = M :-
|
|
M = N + 3.
|
|
|
|
:- pred set(int::in, int::out) is det.
|
|
|
|
set(X, X).
|