Skip to content

v.5.8.4

Yauheni Akhotnikau edited this page Jan 11, 2025 · 1 revision

This page describes changes and new features of v.5.8.4.

More advanced version of so_5::experimental::testing::receives().

The receives() helper was introduced in v.5.8.3, but it had a limitation: receives can only be used once for a pair of (mbox, message-type). This meant that a user couldn't write something like this:

namespace tests = so_5::experimental::testing;
tests::testing_env_t sobj;
...
auto mbox_to_check = sobj.environment().create_mbox();
...
sobj.scenario().define_step("message-is-sent")
    .when(mbox_to_check & tests::receives<some_message>());
...
sobj.scenario().define_step("message-is-sent-another-time")
    .when(mbox_to_check & tests::receives<some_message>()); // (1)

The trigger defined at (1) didn't work because of the limitation of the first implementation of receives() helper. This limitation was removed in v.5.8.4 and now receives can be used several times even for the same (mbox, message-type) pair.

New helper methods for expecting results in testing scenarios

There are new methods has_stored_msg_inspection_result and has_stored_state_name in scenario_proxy_t class:

namespace tests = so_5::experimental::testing;
tests::testing_env_t sobj;

... // Definitions of steps.

sobj.scenario().run_for(15s);

// Checking results.
REQUIRE(tests::completed() == sobj.scenario().result());

// If store_state_name was used in when_any section then we have to
// check the presence of the stored name before checking it.
if(sobj.scenario().has_stored_state_name("my_step", "my_agent"))
    REQUIRE("expected_name" == sobj.scenario().stored_state_name(
        "my_step", "my_agent"));

// If inspect_msg was used in when_any section then we have to check
// the presence of the stored inspection result first.
if(sobj.scenario().has_stored_msg_inspection_result("one", "msg-check"))
    REQUIRE("OK" == sobj.scenario().stored_msg_inspection_result("one", "msg-check"));

Handling of no_wait_on_empty/empty_timeout in receive/select when total_time is set

In the previous versions of SObjectizer values no_wait_on_empty/empty_timeout were ignored in receive/select if total_time was set. This meant that in the following example the receive always took 6s for completion even if ch was empty:

so_5::receive(
    so_5::from(ch).handle_all().no_wait_on_empty().total_time(6s),
    ... /* Message handlers */
);

Since v.5.8.4 values of no_wait_on_empty/empty_timeout are handled properly even in total_time is set. The example above will complete immediately if ch is empty.

Clone this wiki locally