diff --git a/src/libAtomVM/term.c b/src/libAtomVM/term.c index 8a5a3b979..26fd2ed5d 100644 --- a/src/libAtomVM/term.c +++ b/src/libAtomVM/term.c @@ -205,7 +205,7 @@ int term_funprint(PrinterFun *fun, term t, const GlobalContext *global) } else if (term_is_local_port(t)) { // Update also PORT_AS_CSTRING_LEN when changing this format string int32_t process_id = term_to_local_process_id(t); - return fun->print(fun, "#Port<0.%" PRIu32 ".0>", process_id); + return fun->print(fun, "#Port<0.%" PRIu32 ">", process_id); } else if (term_is_external_port(t)) { // Update also PORT_AS_CSTRING_LEN when changing this format string diff --git a/tests/erlang_tests/test_binary_to_term.erl b/tests/erlang_tests/test_binary_to_term.erl index 127e15314..ffc97c2cb 100644 --- a/tests/erlang_tests/test_binary_to_term.erl +++ b/tests/erlang_tests/test_binary_to_term.erl @@ -628,11 +628,11 @@ test_encode_port() -> ExpectedSize = byte_size(Bin), case SupportsV4PortEncoding of true -> - true = is_port( - binary_to_term( - <<131, 120, 119, 13, "nonode@nohost", 1:64, 0:32>> - ) + LocalPort1 = binary_to_term( + <<131, 120, 119, 13, "nonode@nohost", 1:64, 0:32>> ), + true = is_port(LocalPort1), + "#Port<0.1>" = port_to_list(LocalPort1), Port1 = binary_to_term(<<131, 120, 119, 4, "true", 43:64, 0:32>>), Port2 = binary_to_term(<<131, 120, 119, 4, "true", 43:64, 1:32>>), false = Port1 =:= Port2, diff --git a/tests/test.c b/tests/test.c index 650df73a6..c91ac51d7 100644 --- a/tests/test.c +++ b/tests/test.c @@ -190,6 +190,7 @@ struct Test tests[] = { TEST_CASE_EXPECTED(test_atom_to_list, 1), TEST_CASE(test_display), TEST_CASE(test_integer_to_list), + TEST_CASE(test_port_to_list), TEST_CASE_EXPECTED(test_list_to_integer, 99), TEST_CASE_EXPECTED(test_abs, 5), TEST_CASE_EXPECTED(test_is_process_alive, 121),