mirror of
https://github.com/Mercury-Language/mercury.git
synced 2026-04-21 04:13:46 +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.
48 lines
1.1 KiB
Mathematica
48 lines
1.1 KiB
Mathematica
%---------------------------------------------------------------------------%
|
|
% vim: ts=4 sw=4 et ft=mercury
|
|
%---------------------------------------------------------------------------%
|
|
%
|
|
% Test initialisation of mutables by impure functions.
|
|
|
|
:- module mutable_init_impure.
|
|
:- interface.
|
|
|
|
:- import_module io.
|
|
|
|
:- pred main(io::di, io::uo) is det.
|
|
|
|
%---------------------------------------------------------------------------%
|
|
|
|
:- implementation.
|
|
|
|
:- import_module thread.
|
|
:- import_module thread.semaphore.
|
|
|
|
:- mutable(sem1, semaphore, init_sem, ground, [untrailed, attach_to_io_state]).
|
|
:- mutable(sem2, semaphore, init_sem, ground, [untrailed, constant]).
|
|
|
|
:- impure func init_sem = semaphore.
|
|
|
|
init_sem = Sem :-
|
|
impure Sem = semaphore.init(1).
|
|
|
|
:- mutable(foo, string, init_foo, ground, [untrailed, constant]).
|
|
|
|
:- semipure func init_foo = string.
|
|
|
|
init_foo = X :-
|
|
promise_semipure X = "Testing...".
|
|
|
|
main(!IO) :-
|
|
get_sem1(Sem1, !IO),
|
|
semaphore.wait(Sem1, !IO),
|
|
|
|
get_sem2(Sem2),
|
|
semaphore.wait(Sem2, !IO),
|
|
|
|
get_foo(Foo),
|
|
io.write_string(Foo, !IO),
|
|
io.nl(!IO),
|
|
|
|
io.write_string("Success.\n", !IO).
|