Files
mercury/tests/warnings/singleton_test.m
Peter Wang 88047bbb45 Delete Erlang from tests.
tests/general/float_test.exp3:
tests/general/float_test.m:
tests/general/read_dir_regression.exp4:
tests/general/read_dir_regression.m:
tests/hard_coded/remove_file.exp2:
tests/hard_coded/remove_file.m:
    Delete Erlang backend specific expected outputs.

tests/hard_coded/Mmakefile:
tests/hard_coded/erlang_deconstruct.exp:
tests/hard_coded/erlang_deconstruct.m:
tests/hard_coded/existential_list.exp:
tests/hard_coded/existential_list.m:
tests/valid/Mmakefile:
tests/valid/erl_ite_vars.m:
tests/valid/zf_erlang_bug.m:
    Delete erlang target specific tests.

tests/*:
    Delete Erlang foreign procs and foreign types.
2020-10-27 11:10:11 +11:00

83 lines
2.4 KiB
Mathematica

%---------------------------------------------------------------------------%
% vim: ts=4 sw=4 et ft=mercury
%---------------------------------------------------------------------------%
% The .exp files are for C, C# and Java respectively.
:- module singleton_test.
:- interface.
:- import_module io, list.
:- pred my_append(list(int), list(int), list(int)).
:- mode my_append(in, in, out) is det.
:- func my_append_func(list(int), list(int)) = list(int).
:- mode my_append_func(in, in) = out is det.
:- func my_c_func(int, int) = int.
:- mode my_c_func(in, in) = out is det.
:- pred my_c_pred(int, int, int).
:- mode my_c_pred(in, in, out) is det.
:- pred c_hello_world(string::in, io__state::di, io__state::uo) is det.
:- pred test_head(int::in, int::in, int::in, int::in, int::out, int::out)
is det.
:- implementation.
my_append([], L, L) :-
disable_warning [singleton_vars] L = L1,
L = L2.
my_append([H | T], L, [H | NT]) :-
my_append(T, L, NT).
my_append_func([], L) = L :- L1 = L2.
my_append_func([H | T], L) = [H | my_append_func(L, L)].
:- pragma foreign_proc("C", my_c_pred(X::in, Y::in, Z::out),
[promise_pure, will_not_call_mercury], "
Z = 2 * X;
").
:- pragma foreign_proc("C#", my_c_pred(X::in, Y::in, Z::out),
[promise_pure, will_not_call_mercury], "
Z = 2 * X;
").
:- pragma foreign_proc("Java", my_c_pred(X::in, Y::in, Z::out),
[promise_pure, will_not_call_mercury], "
Z = 2 * X;
").
:- pragma foreign_proc("C", my_c_func(X::in, Y::in) = (Z::out),
[promise_pure, will_not_call_mercury], "
Z = 2 * Y;
").
:- pragma foreign_proc("C#", my_c_func(X::in, Y::in) = (Z::out),
[promise_pure, will_not_call_mercury], "
Z = 2 * Y;
").
:- pragma foreign_proc("Java", my_c_func(X::in, Y::in) = (Z::out),
[promise_pure, will_not_call_mercury], "
Z = 2 * Y;
").
:- pragma foreign_decl("C", "#include <stdio.h>").
:- pragma foreign_proc("C", c_hello_world(Msg::in, IO0::di, IO::uo),
[promise_pure, will_not_call_mercury], "
printf(""Hello, world"");
IO = IO0;
").
:- pragma foreign_proc("C#", c_hello_world(Msg::in, IO0::di, IO::uo),
[promise_pure, will_not_call_mercury], "
System.Console.WriteLine(""Hello, world"");
IO = IO0;
").
:- pragma foreign_proc("Java", c_hello_world(Msg::in, IO0::di, IO::uo),
[promise_pure, will_not_call_mercury], "
System.out.println(""Hello, world"");
IO = IO0;
").
test_head(A, B, C, _D, C, _D).