mirror of
https://github.com/Mercury-Language/mercury.git
synced 2026-04-15 17:33:38 +00:00
52 lines
1.1 KiB
Mathematica
52 lines
1.1 KiB
Mathematica
%---------------------------------------------------------------------------%
|
|
% vim: ts=4 sw=4 et ft=mercury
|
|
%---------------------------------------------------------------------------%
|
|
%
|
|
% Check that the dummy type optimisation is disabled for foreign enumerations.
|
|
%
|
|
|
|
:- module foreign_enum_dummy.
|
|
:- interface.
|
|
|
|
:- import_module io.
|
|
|
|
:- pred main(io::di, io::uo) is det.
|
|
|
|
:- implementation.
|
|
|
|
:- import_module bool.
|
|
|
|
main(!IO) :-
|
|
( if test(foo) then
|
|
io.write_string("Success.\n", !IO)
|
|
else
|
|
io.write_string("Failure.\n", !IO)
|
|
).
|
|
|
|
:- pred test(foo::in) is semidet.
|
|
:- pragma foreign_proc("C",
|
|
test(FOO::in),
|
|
[will_not_call_mercury, promise_pure],
|
|
"
|
|
if (FOO == 561) {
|
|
SUCCESS_INDICATOR = MR_TRUE;
|
|
} else {
|
|
SUCCESS_INDICATOR = MR_FALSE;
|
|
}
|
|
").
|
|
:- pragma foreign_proc("C#",
|
|
test(FOO::in),
|
|
[will_not_call_mercury, promise_pure],
|
|
"
|
|
if ((int) FOO == 561) {
|
|
SUCCESS_INDICATOR = true;
|
|
} else {
|
|
SUCCESS_INDICATOR = false;
|
|
}
|
|
").
|
|
|
|
:- type foo
|
|
---> foo.
|
|
:- pragma foreign_enum("C", foo/0, [foo - "561"]).
|
|
:- pragma foreign_enum("C#", foo/0, [foo - "561"]).
|