mirror of
https://github.com/Mercury-Language/mercury.git
synced 2026-04-21 04:13:46 +00:00
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.
74 lines
2.1 KiB
Mathematica
74 lines
2.1 KiB
Mathematica
%---------------------------------------------------------------------------%
|
|
% vim: ts=4 sw=4 et ft=mercury
|
|
%---------------------------------------------------------------------------%
|
|
%
|
|
% This is a regression test.
|
|
%
|
|
% The Mercury compiler of 26/10/1999 failed the first part of this test
|
|
% (the part concerned with the implied mode of append).
|
|
%
|
|
% The Mercury compiler of 30/3/2000 failed the second part of this test
|
|
% (the part with comparison_test1), due to overeager specialization of
|
|
% comparisons involving ENUM_USEREQ types.
|
|
%
|
|
% The Mercury compiler still fails the third part of this test (the part
|
|
% with comparison_test2) with --no-special-preds, because the exception
|
|
% is not propagated across MR_call_engine properly. (It should work fine
|
|
% with the default --special-preds.)
|
|
|
|
:- module user_defined_equality.
|
|
:- interface.
|
|
:- import_module io.
|
|
|
|
:- pred main(io::di, io::uo) is cc_multi.
|
|
|
|
:- implementation.
|
|
:- import_module list.
|
|
:- import_module std_util.
|
|
:- import_module exception.
|
|
|
|
:- type foo
|
|
---> bar
|
|
; baz
|
|
where equality is foo_equal.
|
|
|
|
foo_equal(_, _) :-
|
|
semidet_succeed.
|
|
|
|
main(!IO) :-
|
|
( if append([bar], [baz], [baz, bar]) then
|
|
io.write_string("yes\n", !IO)
|
|
else
|
|
io.write_string("no\n", !IO)
|
|
),
|
|
perform_comparison_test(comparison_test1, !IO),
|
|
perform_comparison_test(comparison_test2, !IO).
|
|
|
|
:- pred perform_comparison_test(pred(T), io.state, io.state).
|
|
:- mode perform_comparison_test(pred(out) is det, di, uo) is cc_multi.
|
|
|
|
perform_comparison_test(Test, !IO) :-
|
|
try(Test, TryResult),
|
|
(
|
|
TryResult = failed,
|
|
io.write_string("failed\n", !IO)
|
|
;
|
|
TryResult = succeeded(Result),
|
|
io.write_string("succeeded: ", !IO),
|
|
io.write_line(Result, !IO)
|
|
;
|
|
TryResult = exception(Exception),
|
|
io.write_string("threw exception: ", !IO),
|
|
io.write_line(Exception, !IO)
|
|
).
|
|
|
|
:- pred comparison_test1(comparison_result::out) is det.
|
|
|
|
comparison_test1(R) :-
|
|
compare(R, bar, baz).
|
|
|
|
:- pred comparison_test2(comparison_result::out) is det.
|
|
|
|
comparison_test2(R) :-
|
|
compare(R, [bar], [baz]).
|