mirror of
https://github.com/Mercury-Language/mercury.git
synced 2026-04-26 14:54:17 +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.
114 lines
2.7 KiB
Mathematica
114 lines
2.7 KiB
Mathematica
%---------------------------------------------------------------------------%
|
|
% vim: ts=4 sw=4 et ft=mercury
|
|
%---------------------------------------------------------------------------%
|
|
%
|
|
:- module cut_test.
|
|
|
|
:- interface.
|
|
|
|
:- import_module io.
|
|
|
|
:- pred main(io__state::di, io__state::uo) is det.
|
|
|
|
:- implementation.
|
|
|
|
:- import_module int.
|
|
|
|
main -->
|
|
( { best(100) } ->
|
|
io__write_string("best case nondet test 1 succeeded: BUG.\n")
|
|
;
|
|
io__write_string("best case nondet test 1 failed: OK.\n")
|
|
),
|
|
( { best(300) } ->
|
|
io__write_string("best case nondet test 2 succeeded: OK.\n")
|
|
;
|
|
io__write_string("best case nondet test 2 failed: BUG.\n")
|
|
),
|
|
( { middle(100) } ->
|
|
io__write_string("middle case nondet test 1 succeeded: BUG.\n")
|
|
;
|
|
io__write_string("middle case nondet test 1 failed: OK.\n")
|
|
),
|
|
( { middle(180) } ->
|
|
io__write_string("middle case nondet test 2 succeeded: OK.\n")
|
|
;
|
|
io__write_string("middle case nondet test 2 failed: BUG.\n")
|
|
),
|
|
( { middle(190) } ->
|
|
io__write_string("middle case nondet test 3 succeeded: OK.\n")
|
|
;
|
|
io__write_string("middle case nondet test 3 failed: BUG.\n")
|
|
),
|
|
( { middle(200) } ->
|
|
io__write_string("middle case nondet test 4 succeeded: OK.\n")
|
|
;
|
|
io__write_string("middle case nondet test 4 failed: BUG.\n")
|
|
),
|
|
( { worst(100) } ->
|
|
io__write_string("worst case nondet test 1 succeeded: BUG.\n")
|
|
;
|
|
io__write_string("worst case nondet test 1 failed: OK.\n")
|
|
),
|
|
( { worst(180) } ->
|
|
io__write_string("worst case nondet test 2 succeeded: OK.\n")
|
|
;
|
|
io__write_string("worst case nondet test 2 failed: BUG.\n")
|
|
),
|
|
( { worst(190) } ->
|
|
io__write_string("worst case nondet test 3 succeeded: OK.\n")
|
|
;
|
|
io__write_string("worst case nondet test 3 failed: BUG.\n")
|
|
),
|
|
( { worst(200) } ->
|
|
io__write_string("worst case nondet test 4 succeeded: OK.\n")
|
|
;
|
|
io__write_string("worst case nondet test 4 failed: BUG.\n")
|
|
).
|
|
|
|
:- pred best(int::in) is semidet.
|
|
|
|
best(A) :-
|
|
test(A, _).
|
|
|
|
:- pred middle(int::in) is semidet.
|
|
|
|
middle(A0) :-
|
|
(
|
|
A1 = A0 + 10
|
|
;
|
|
A1 = A0 + 20
|
|
;
|
|
A1 = A0 + 30
|
|
),
|
|
test(A1, _).
|
|
|
|
:- pred worst(int::in) is semidet.
|
|
|
|
worst(A0) :-
|
|
addsome(A0, A1),
|
|
test(A1, _).
|
|
|
|
:- pred addsome(int::in, int::out) is multi.
|
|
|
|
addsome(A0, A1) :-
|
|
(
|
|
A1 = A0 + 10
|
|
;
|
|
A1 = A0 + 20
|
|
;
|
|
A1 = A0 + 30
|
|
).
|
|
|
|
:- pred test(int::in, int::out) is nondet.
|
|
|
|
test(A, B) :-
|
|
A > 200,
|
|
(
|
|
B = A
|
|
;
|
|
B = A * 2
|
|
;
|
|
B = A * 3
|
|
).
|