mirror of
https://github.com/Mercury-Language/mercury.git
synced 2026-04-16 18:03:36 +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.
60 lines
1.4 KiB
Mathematica
60 lines
1.4 KiB
Mathematica
%---------------------------------------------------------------------------%
|
|
% vim: ts=4 sw=4 et ft=mercury
|
|
%---------------------------------------------------------------------------%
|
|
|
|
:- module array_sort.
|
|
:- interface.
|
|
|
|
:- import_module io.
|
|
|
|
:- pred main(io::di, io::uo) is cc_multi.
|
|
|
|
%---------------------------------------------------------------------------%
|
|
%---------------------------------------------------------------------------%
|
|
|
|
:- implementation.
|
|
|
|
:- import_module array.
|
|
:- import_module list.
|
|
:- import_module solutions.
|
|
|
|
%---------------------------------------------------------------------------%
|
|
|
|
main(!IO) :-
|
|
array.sort_fix_2014,
|
|
unsorted_aggregate(generate, test, !IO),
|
|
io.write_string("done.\n", !IO).
|
|
|
|
:- pred generate(list(int)::out) is multi.
|
|
|
|
generate(L) :-
|
|
L0 = [0, 0, 1, 1, 2, 2, 3, 3],
|
|
sub(L0, L1),
|
|
list.perm(L1, L).
|
|
|
|
:- pred sub(list(T)::in, list(T)::out) is multi.
|
|
|
|
sub([], []).
|
|
sub([_ | T], L) :-
|
|
sub(T, L).
|
|
sub([H | T], [H | L]) :-
|
|
sub(T, L).
|
|
|
|
:- pred test(list(int)::in, io::di, io::uo) is det.
|
|
|
|
test(L, !IO) :-
|
|
list.sort(L, LS),
|
|
AS = to_list(array.sort(from_list(L))),
|
|
( LS = AS ->
|
|
% io.write_string("ok: ", !IO),
|
|
% io.write(L, !IO),
|
|
% io.nl(!IO)
|
|
true
|
|
;
|
|
io.write_string("failed: ", !IO),
|
|
io.write(L, !IO),
|
|
io.write_string(" -> ", !IO),
|
|
io.write(AS, !IO),
|
|
io.nl(!IO)
|
|
).
|