mirror of
https://github.com/Mercury-Language/mercury.git
synced 2026-04-15 09:23:44 +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.
49 lines
1.2 KiB
Mathematica
49 lines
1.2 KiB
Mathematica
%---------------------------------------------------------------------------%
|
|
% vim: ft=mercury ff=unix ts=4 sw=4 et
|
|
%
|
|
% This test case models some code in g12/common/g12/propagator.m that is
|
|
% a challenge for the state variable transformation.
|
|
%
|
|
%---------------------------------------------------------------------------%
|
|
|
|
:- module state_var_trace.
|
|
|
|
:- interface.
|
|
|
|
:- import_module io.
|
|
|
|
:- pred main(io::di, io::uo) is det.
|
|
|
|
%---------------------------------------------------------------------------%
|
|
%---------------------------------------------------------------------------%
|
|
|
|
:- implementation.
|
|
|
|
:- import_module int.
|
|
:- import_module list.
|
|
:- import_module string.
|
|
|
|
main(!IO) :-
|
|
X0 = 10,
|
|
p(0, B, X0, X),
|
|
io.format("B = %d\n", [i(B)], !IO),
|
|
io.format("X = %d\n", [i(X)], !IO).
|
|
|
|
:- pred p(int::in, int::out, int::di, int::uo) is det.
|
|
|
|
p(A, B, !X) :-
|
|
trace [
|
|
compiletime(flag("state_var_trace")),
|
|
io(!TIO)
|
|
] (
|
|
ui_format("A ", A, !TIO),
|
|
ui_format("!.X", !.X, !TIO)
|
|
),
|
|
B = A + 1.
|
|
|
|
:- pred ui_format(string::in, int::ui, io::di, io::uo) is det.
|
|
|
|
ui_format(Name, Var, !IO) :-
|
|
copy(Var, VarCopy),
|
|
io.format("%s = %d\n", [s(Name), i(VarCopy)], !IO).
|