mirror of
https://github.com/Mercury-Language/mercury.git
synced 2026-04-17 18:33:58 +00:00
tests/accumulator/*.m:
tests/analysis_*/*.m:
tests/benchmarks*/*.m:
tests/debugger*/*.{m,exp,inp}:
tests/declarative_debugger*/*.{m,exp,inp}:
tests/dppd*/*.m:
tests/exceptions*/*.m:
tests/general*/*.m:
tests/grade_subdirs*/*.m:
tests/hard_coded*/*.m:
Make these tests use four-space indentation, and ensure that
each module is imported on its own line. (I intend to use the latter
to figure out which subdirectories' tests can be executed in parallel.)
These changes usually move code to different lines. For the debugger tests,
specify the new line numbers in .inp files and expect them in .exp files.
74 lines
1.9 KiB
Mathematica
74 lines
1.9 KiB
Mathematica
%---------------------------------------------------------------------------%
|
|
% vim: ts=4 sw=4 et ft=mercury
|
|
%---------------------------------------------------------------------------%
|
|
%
|
|
% A test of the Java interface.
|
|
|
|
:- module java_test.
|
|
:- interface.
|
|
:- import_module io.
|
|
|
|
:- pred main(io__state::di, io__state::uo) is det.
|
|
|
|
:- implementation.
|
|
:- import_module int.
|
|
|
|
:- func foo(int) = int.
|
|
/*
|
|
XXX `pragma export' not yet supported for Java
|
|
:- pragma export(foo(in) = out, "foo").
|
|
*/
|
|
foo(X) = X + 1.
|
|
|
|
main -->
|
|
java_write_string("Hello, world\n"),
|
|
( { java_semidet_succeed } ->
|
|
[]
|
|
;
|
|
java_write_string("java_semidet_succeed failed\n")
|
|
),
|
|
( { java_semidet_fail } ->
|
|
java_write_string("java_semidet_fail succeeded\n")
|
|
;
|
|
[]
|
|
).
|
|
|
|
:- pragma foreign_decl("Java", "
|
|
// some Java top-level declarations
|
|
class Foo {}
|
|
").
|
|
|
|
:- pragma foreign_code("Java", "
|
|
// some Java in-class declarations
|
|
static void bar() {
|
|
/*
|
|
XXX `pragma export' not yet supported for Java
|
|
// test `pragma export' functions
|
|
if (foo(42) != 43) {
|
|
throw new java.lang.Error(""bar: foo failed"");
|
|
}
|
|
*/
|
|
}
|
|
").
|
|
|
|
:- pred java_write_string(string::in, io__state::di, io__state::uo) is det.
|
|
|
|
:- pragma foreign_proc("Java",
|
|
java_write_string(Message::in, _IO0::di, _IO::uo),
|
|
[will_not_call_mercury, promise_pure],
|
|
"
|
|
// a Java procedure
|
|
System.out.print(Message);
|
|
// test that foreign_decl declarations are visible
|
|
Foo f;
|
|
// test that foreign_code declarations are visible
|
|
bar();
|
|
").
|
|
|
|
:- pred java_semidet_succeed is semidet.
|
|
:- pred java_semidet_fail is semidet.
|
|
:- pragma foreign_proc("Java", java_semidet_succeed,
|
|
[will_not_call_mercury, promise_pure], "SUCCESS_INDICATOR = true;").
|
|
:- pragma foreign_proc("Java", java_semidet_fail,
|
|
[will_not_call_mercury, promise_pure], "SUCCESS_INDICATOR = false;").
|