Files
mercury/tests/hard_coded/pragma_export.m
Julien Fischer f9f2e5e112 Enable a test case in the C# and Java grades.
test/hard_coded/Mmakefile:
    Run the pragma_export test in C# and Java grades.

tests/hard_coded/pragma_export.m:
    Add the foreign_proc and foreign_export pragmas required for
    this to work in the Java grade.
2021-01-07 14:08:04 +11:00

45 lines
1.3 KiB
Mathematica

%---------------------------------------------------------------------------%
% vim: ts=4 sw=4 et ft=mercury
%---------------------------------------------------------------------------%
%
% This test case tests using `pragma foreign_export' on a procedure defined
% in a different module (in this case, one from the standard library).
% Previously the MLDS back-end was failing this test case.
:- module pragma_export.
:- interface.
:- import_module io.
:- pred main(io::di, io::uo) is det.
:- implementation.
main(!IO) :-
my_write_string("pragma_export test succeeded\n", !IO).
:- pred my_write_string(string::in, io::di, io::uo) is det.
:- pragma foreign_proc("C",
my_write_string(Str::in, _IO0::di, _IO::uo),
[promise_pure, may_call_mercury, thread_safe],
"
write_str(Str);
").
:- pragma foreign_proc("C#",
my_write_string(Str::in, _IO0::di, _IO::uo),
[promise_pure, may_call_mercury, thread_safe],
"
write_str(Str);
").
:- pragma foreign_proc("Java",
my_write_string(Str::in, _IO0::di, _IO::uo),
[promise_pure, may_call_mercury, thread_safe],
"
write_str(Str);
").
:- pragma foreign_export("C", io.write_string(in, di, uo), "write_str").
:- pragma foreign_export("C#", io.write_string(in, di, uo), "write_str").
:- pragma foreign_export("Java", io.write_string(in, di, uo), "write_str").