mirror of
https://github.com/Mercury-Language/mercury.git
synced 2025-12-13 04:44:39 +00:00
Add some thread-local mutables to these test cases.
Estimated hours taken: 0 Branches: main tests/hard_coded/mutable_decl.exp: tests/hard_coded/mutable_decl.m: tests/hard_coded/pure_mutable.exp: tests/hard_coded/pure_mutable.m: tests/invalid/bad_mutable.err_exp: tests/invalid/bad_mutable.m: Add some thread-local mutables to these test cases. (Forgot to commit them earlier.)
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
0, 1, 2
|
||||
0
|
||||
5
|
||||
5
|
||||
|
||||
@@ -31,6 +31,8 @@
|
||||
|
||||
:- mutable(y, int, 0, ground, [untrailed]).
|
||||
|
||||
:- mutable(z, int, 0, ground, [untrailed, thread_local]).
|
||||
|
||||
main(!IO) :-
|
||||
semipure get_x(X0), impure set_x(X0 + 1),
|
||||
semipure get_x(X1), impure set_x(X1 + 1),
|
||||
@@ -43,13 +45,15 @@ main(!IO) :-
|
||||
else true
|
||||
),
|
||||
semipure get_x(X), io.write_int(X, !IO), io.nl(!IO),
|
||||
semipure get_y(Y), io.write_int(Y, !IO), io.nl(!IO).
|
||||
semipure get_y(Y), io.write_int(Y, !IO), io.nl(!IO),
|
||||
semipure get_z(Z), io.write_int(Z, !IO), io.nl(!IO).
|
||||
|
||||
:- impure pred my_member(int::in, list(int)::in) is nondet.
|
||||
|
||||
my_member(A, [B | Bs]) :-
|
||||
semipure get_x(X), impure set_x(X + 1),
|
||||
semipure get_y(Y), impure set_y(Y + 1),
|
||||
semipure get_z(Z), impure set_z(Z + 1),
|
||||
(
|
||||
A = B
|
||||
;
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
Initial value of global = 561
|
||||
Final value of global = 562
|
||||
Value of const = 562
|
||||
Initial value of thrlocal = 563
|
||||
Final value of thrlocal = 564
|
||||
|
||||
@@ -17,6 +17,9 @@
|
||||
|
||||
:- mutable(const, int, 562, ground, [constant]).
|
||||
|
||||
:- mutable(thrlocal, int, 563, ground,
|
||||
[untrailed, attach_to_io_state, thread_local]).
|
||||
|
||||
main(!IO) :-
|
||||
get_global(X0, !IO),
|
||||
io.format("Initial value of global = %d\n", [i(X0)], !IO),
|
||||
@@ -25,4 +28,11 @@ main(!IO) :-
|
||||
io.format("Final value of global = %d\n", [i(X)], !IO),
|
||||
|
||||
get_const(C),
|
||||
io.format("Value of const = %d\n", [i(C)], !IO).
|
||||
io.format("Value of const = %d\n", [i(C)], !IO),
|
||||
|
||||
get_thrlocal(Y0, !IO),
|
||||
io.format("Initial value of thrlocal = %d\n", [i(Y0)], !IO),
|
||||
set_thrlocal(Y0 + 1, !IO),
|
||||
get_thrlocal(Y, !IO),
|
||||
io.format("Final value of thrlocal = %d\n", [i(Y)], !IO).
|
||||
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
bad_mutable.m:015: Error: malformed attribute list in mutable declaration: [untrailed, bad_attrib].
|
||||
bad_mutable.m:017: Error: the type in a mutable declaration cannot contain variables: list(_1).
|
||||
bad_mutable.m:019: Error: conflicting attributes in attribute list: [untrailed, trailed].
|
||||
bad_mutable.m:024: Error: conflicting attributes in attribute list: [thread_local, trailed].
|
||||
bad_mutable.m:026: Error: conflicting attributes in attribute list: [thread_local, constant].
|
||||
bad_mutable.m:011: In declaration for mutable `not_a_type':
|
||||
bad_mutable.m:011: error: undefined type `no_type'/0.
|
||||
bad_mutable.m:013: In declaration for mutable `not_an_inst':
|
||||
|
||||
@@ -20,3 +20,8 @@
|
||||
|
||||
:- mutable(multiple_foreign, int, 0, ground,
|
||||
[untrailed, foreign_name("C", "one"), foreign_name("C", "two")]).
|
||||
|
||||
:- mutable(conflicting_thr_local1, int, 0, ground, [thread_local, trailed]).
|
||||
|
||||
:- mutable(conflicting_thr_local2, int, 0, ground, [thread_local, constant]).
|
||||
|
||||
|
||||
Reference in New Issue
Block a user