Skip to content

Commit 4b23228

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

File tree

4 files changed

+14
-14
lines changed

4 files changed

+14
-14
lines changed

libs/estdlib/src/erlang.erl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1179,9 +1179,9 @@ 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
1182+
%% Currently, only the {alias, AliasMode} option is supported. Passing it
11831183
%% makes the monitor also an alias on the calling process (see `alias/0`).
1184-
%% `AliasMode` defines the behaviour of the alias:
1184+
%% AliasMode defines the behaviour of the alias:
11851185
%% - explicit_unalias - the alias can be only removed with `unalias/1`,
11861186
%% - demonitor - the alias is also removed when `demonitor/1` is called
11871187
%% on the monitor,

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)