Files
mercury/tests/hard_coded/promise_equivalent_solutions_test.m
Julien Fischer 1f6d83692a Update programming style in tests/hard_coded.
tests/hard_coded/*.m:
    Update programming style, unless doing so would change
    the meaning of the test, in particular:

    - use '.' as a module qualifier in place of '__'
    - use {write,print}_line where appropriate
    - use if-then-else in place of C -> T ; E
    - use state variables in place of DCGs

tests/hard_coded/dir_test.m:
    Document what the expected outputs correspond to.

    Use a uniform module qualifier in the output.

tests/hard_coded/dir_test.exp*:
    Conform to the above change.
2021-01-07 13:58:12 +11:00

50 lines
1.3 KiB
Mathematica

%---------------------------------------------------------------------------%
% vim: ts=4 sw=4 et ft=mercury
%---------------------------------------------------------------------------%
%
% Various checks that promise_equivalent_solutions goals are treated properly.
:- module promise_equivalent_solutions_test.
:- interface.
:- import_module io.
:- pred main(io::di, io::uo) is det.
:- implementation.
:- import_module int.
:- import_module list.
:- import_module string.
main(!IO) :-
% The equality theory with respect to which all solutions of the goal
% inside the promise_equivalent_solution are equivalent is the one that
% views the lists as unsorted representations of sets, possibly with
% duplicates.
promise_equivalent_solutions [A, B] (
( A = [1, 2]
; A = [2, 1]
),
( B = [44, 33]
; B = [33, 44]
)
),
list.sort_and_remove_dups(A, ASorted),
list.sort_and_remove_dups(B, BSorted),
io.write_line(ASorted, !IO),
io.write_line(BSorted, !IO),
(
promise_equivalent_solutions [C] (
ASorted = [_ | ATail],
( C = [5] ++ ATail
; C = ATail ++ [5]
)
)
->
list.sort_and_remove_dups(C, CSorted),
io.write_line(CSorted, !IO)
;
io.write("cannot compute CSorted\n", !IO)
).