mirror of
https://github.com/Mercury-Language/mercury.git
synced 2026-04-17 10: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.
83 lines
1.1 KiB
Mathematica
83 lines
1.1 KiB
Mathematica
%---------------------------------------------------------------------------%
|
|
% vim: ts=4 sw=4 et ft=mercury
|
|
%---------------------------------------------------------------------------%
|
|
|
|
:- module throw.
|
|
:- interface.
|
|
:- import_module io.
|
|
:- pred main(io__state, io__state).
|
|
:- mode main(di, uo) is cc_multi.
|
|
|
|
:- implementation.
|
|
|
|
:- import_module exception.
|
|
:- import_module int.
|
|
|
|
main -->
|
|
{ try(p, X) },
|
|
io__write(X),
|
|
io__nl,
|
|
{ try(q, Y) },
|
|
io__write(Y),
|
|
io__nl.
|
|
|
|
:- pred p(int::out) is cc_nondet.
|
|
|
|
p(X) :-
|
|
a(A),
|
|
b(A, X),
|
|
X < 0.
|
|
|
|
:- pred a(int::out) is multi.
|
|
|
|
a(2).
|
|
a(3).
|
|
|
|
:- pred b(int::in, int::out) is multi.
|
|
|
|
b(A, B) :-
|
|
(
|
|
B = A * 3
|
|
;
|
|
B = A * 4
|
|
),
|
|
(
|
|
B > 10
|
|
->
|
|
throw("Too big")
|
|
;
|
|
true
|
|
).
|
|
|
|
:- pred q(int::out) is semidet.
|
|
|
|
q(1) :-
|
|
not (
|
|
a2(A),
|
|
not (
|
|
b2(A, 0)
|
|
),
|
|
A < 0
|
|
).
|
|
|
|
:- pred a2(int::out) is multi.
|
|
|
|
a2(2).
|
|
a2(3).
|
|
|
|
:- pred b2(int::in, int::out) is multi.
|
|
|
|
b2(A, B) :-
|
|
(
|
|
B = A * 3
|
|
;
|
|
B = A * 4
|
|
),
|
|
(
|
|
B > 10
|
|
->
|
|
throw("Too big")
|
|
;
|
|
true
|
|
).
|