Skip to content

Commit 07373d0

Browse files
committed
fix alias dead process test
Signed-off-by: Mateusz Front <[email protected]>
1 parent 258139a commit 07373d0

File tree

4 files changed

+21
-21
lines changed

4 files changed

+21
-21
lines changed

libs/estdlib/src/erlang.erl

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1179,11 +1179,11 @@ monitor(_Type, _PidOrPort) ->
11791179
%% @param Options monitor options
11801180
%% @returns a monitor reference
11811181
%% @doc Creates a monitor and allows passing additional options.
1182-
%% Currently, only the `{alias, AliasMode}` option is supported. Passing it
1183-
%% makes the monitor also an alias on the calling process (see `alias/0`).
1184-
%% `AliasMode` defines the behaviour of the alias:
1185-
%% - explicit_unalias - the alias can be only removed with `unalias/1`,
1186-
%% - demonitor - the alias is also removed when `demonitor/1` is called
1182+
%% Currently, only the `{alias, AliasMode}' option is supported. Passing it
1183+
%% makes the monitor also an alias on the calling process (see `alias/0').
1184+
%% `AliasMode' defines the behaviour of the alias:
1185+
%% - explicit_unalias - the alias can be only removed with `unalias/1',
1186+
%% - demonitor - the alias is also removed when `demonitor/1' is called
11871187
%% on the monitor,
11881188
%% - reply_demonitor - the alias is also removed after a first message
11891189
%% is sent via it.
@@ -1611,8 +1611,8 @@ raise(_Class, _Reason, _Stacktrace) ->
16111611
%% @returns A reference aliasing the calling process.
16121612
%% @doc Creates an alias for the callling process. The alias can be used
16131613
%% to send messages to the process like the PID. The alias can also be
1614-
%% created along with a monitor - see `monitor/3`. The alias can be
1615-
%% removed by calling `unalias/1`.
1614+
%% created along with a monitor - see `monitor/3'. The alias can be
1615+
%% removed by calling `unalias/1'.
16161616
%% @end
16171617
%%-----------------------------------------------------------------------------
16181618
-spec alias() -> Alias when Alias :: reference().
@@ -1621,8 +1621,8 @@ alias() ->
16211621

16221622
%%-----------------------------------------------------------------------------
16231623
%% @param Alias the alias to be removed.
1624-
%% @returns `true` if alias was removed, `false` if it was not found
1625-
%% @doc Removes process alias. See `alias/0` for more information.
1624+
%% @returns `true' if alias was removed, `false' if it was not found
1625+
%% @doc Removes process alias. See `alias/0' for more information.
16261626
%% @end
16271627
%%-----------------------------------------------------------------------------
16281628
-spec unalias(Alias) -> boolean() when Alias :: reference().

src/libAtomVM/term.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1871,7 +1871,7 @@ static inline bool term_is_nomatch_binary_pos_len(BinaryPosLen pos_len)
18711871

18721872
static inline BinaryPosLen term_nomatch_binary_pos_len(void)
18731873
{
1874-
return (BinaryPosLen) { .pos = -1, .len = -1 };
1874+
return (BinaryPosLen){ .pos = -1, .len = -1 };
18751875
}
18761876

18771877
/**

tests/erlang_tests/test_binary_to_term.erl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1141,7 +1141,7 @@ test_encode_process_ref() ->
11411141
AliasesAvailable = is_atomvm_or_otp_version_at_least("23"),
11421142
if
11431143
AliasesAvailable ->
1144-
ProcessRef = alias(),
1144+
ProcessRef = erlang:alias(),
11451145
ProcessRef = binary_to_term(term_to_binary(ProcessRef)),
11461146
ok;
11471147
true ->

tests/erlang_tests/test_monitor.erl

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ start() ->
4646
ok = test_multiple_aliases(),
4747
ok = test_multiple_unaliases(),
4848
ok = test_unalias_from_wrong_process(),
49+
ok = test_monitor_alias_dead_process(),
4950
ok = test_monitor_multiple_aliases_monitors(fun spawn_monitor/2),
5051
ok = test_monitor_multiple_aliases_monitors(fun spawn_and_monitor/2),
5152
ok = test_monitor_alias_demonitor(fun spawn_monitor/2),
@@ -56,8 +57,6 @@ start() ->
5657
ok = test_monitor_alias_reply_demonitor(fun spawn_and_monitor/2),
5758
ok = test_monitor_down_alias(fun spawn_monitor/2),
5859
ok = test_monitor_down_alias(fun spawn_and_monitor/2),
59-
ok = test_monitor_alias_dead_process(fun spawn_monitor/2),
60-
ok = test_monitor_alias_dead_process(fun spawn_and_monitor/2),
6160
ok;
6261
true ->
6362
ok
@@ -347,14 +346,15 @@ test_monitor_multiple_aliases_monitors(SpawnFun) ->
347346
{'DOWN', Mon4, process, P, normal} = recv_one(),
348347
ok.
349348

350-
test_monitor_alias_dead_process(SpawnFun) ->
351-
Noop = fun() -> ok end,
352-
{P1, Mon1} = SpawnFun(Noop, [{alias, demonitor}]),
353-
{'DOWN', Mon1, process, P1, normal} = recv_one(),
354-
{P2, Mon2} = SpawnFun(Noop, [{alias, reply_demonitor}]),
355-
{'DOWN', Mon2, process, P2, normal} = recv_one(),
356-
{P3, Mon3} = SpawnFun(Noop, [{alias, explicit_unalias}]),
357-
{'DOWN', Mon3, process, P3, normal} = recv_one(),
349+
test_monitor_alias_dead_process() ->
350+
{P, Mon0} = spawn_opt(fun() -> ok end, [monitor]),
351+
{'DOWN', Mon0, process, P, normal} = recv_one(),
352+
Mon1 = erlang:monitor(process, P, [{alias, demonitor}]),
353+
{'DOWN', Mon1, process, P, noproc} = recv_one(),
354+
Mon2 = erlang:monitor(process, P, [{alias, reply_demonitor}]),
355+
{'DOWN', Mon2, process, P, noproc} = recv_one(),
356+
Mon3 = erlang:monitor(process, P, [{alias, explicit_unalias}]),
357+
{'DOWN', Mon3, process, P, noproc} = recv_one(),
358358
ok.
359359

360360
spawn_monitor(LoopFun, Opts) ->

0 commit comments

Comments
 (0)