test_lambda_thread_spawns.py

tests/test_lambda_thread_spawns.py

A thread that exists in the source and in no index row.

test_a_lambda_bodied_spawn_is_harvested

None test_lambda_thread_spawns.test_a_lambda_bodied_spawn_is_harvested()

Every lambda-bodied spawn must be harvested, not dropped.

tests/test_lambda_thread_spawns.py:107

Show on the map →

Called by none

Calls _walk_spawn_sites, load_thread_patterns, patterns_by_name

Checks

  • assert len(sites) == 5, (f"expected 5 spawn sites (1 named + 4 lambda-bodied), got {len(sites)}: " f"{[s[0] for s in sites]}" )

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-PIPE-003measuredtest_a_lambda_bodied_spawn_is_harvested → _walk_spawn_sites → is_python_tree
REQ-DDB-SCHEMA-001measuredtest_a_lambda_bodied_spawn_is_harvested → load_thread_patterns
REQ-DDB-SCHEMA-012inferredtest_a_lambda_bodied_spawn_is_harvested → load_thread_patterns → declaration_origin
Source · 19 lines
def test_a_lambda_bodied_spawn_is_harvested() -> None:
    """FIVE SITES IN THIS FIXTURE: one named entry and four lambdas, three assigned and one
    detached temporary. Before the fix only the named one survived.

    @brief All five spawn sites are seen.
    @return None.
    @version 1
    """
    patterns = patterns_by_name(load_thread_patterns(None))
    tree, src = _parse(_LAMBDA_FORMS)

    sites = _walk_spawn_sites(tree, src, patterns)

    assert len(sites) == 5, (
        f"expected 5 spawn sites (1 named + 4 lambda-bodied), got {len(sites)}: "
        f"{[s[0] for s in sites]}"
    )

Activity · 4 steps
lines 115–115patterns = patterns_by_name(load_thread_patterns(None))lines 116–116tree, src = _parse(_LAMBDA_FORMS)lines 118–118sites = _walk_spawn_sites(tree, src, patterns)lines 120–123assert len(sites) == 5, ( f"expected 5 spawn sites (1 named + 4 lambda-bodied), got {len(sites)}: " f"{[s[0] for s in sites]}" )

test_the_named_entry_control_still_resolves

None test_lambda_thread_spawns.test_the_named_entry_control_still_resolves()

The named-entry control must still resolve to its entry function.

tests/test_lambda_thread_spawns.py:130

Show on the map →

Called by none

Calls _walk_spawn_sites, load_thread_patterns, patterns_by_name

Checks

  • assert "monitor_loop" in entries, f"the named entry stopped resolving: {entries}"

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-PIPE-003measuredtest_the_named_entry_control_still_resolves → _walk_spawn_sites → is_python_tree
REQ-DDB-SCHEMA-001measuredtest_the_named_entry_control_still_resolves → load_thread_patterns
REQ-DDB-SCHEMA-012inferredtest_the_named_entry_control_still_resolves → load_thread_patterns → declaration_origin
Source · 17 lines
def test_the_named_entry_control_still_resolves() -> None:
    """THE TWO-SIDED ASSERTION. Recording unnameable entries must not cost the nameable ones, and
    a test that only counted rows would not notice if it had.

    @brief A named entry keeps its entry name.
    @return None.
    @version 1
    """
    patterns = patterns_by_name(load_thread_patterns(None))
    tree, src = _parse(_LAMBDA_FORMS)

    sites = _walk_spawn_sites(tree, src, patterns)
    entries = [s[1] for s in sites]

    assert "monitor_loop" in entries, f"the named entry stopped resolving: {entries}"

Activity · 5 steps
lines 138–138patterns = patterns_by_name(load_thread_patterns(None))lines 139–139tree, src = _parse(_LAMBDA_FORMS)lines 141–141sites = _walk_spawn_sites(tree, src, patterns)lines 142–142entries = [s[1] for s in sites]lines 144–144assert "monitor_loop" in entries, f"the named entry stopped resolving: {entries}"

test_unnamed_spawns_get_distinct_names

None test_lambda_thread_spawns.test_unnamed_spawns_get_distinct_names()

Unnamed spawns must carry distinct names, or they collapse to one row.

tests/test_lambda_thread_spawns.py:151

Show on the map →

Called by none

Calls _walk_spawn_sites, load_thread_patterns, patterns_by_name

Checks

  • assert len(set(names)) == len(names), f"spawn names collide and would collapse rows: {names}"

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-PIPE-003measuredtest_unnamed_spawns_get_distinct_names → _walk_spawn_sites → is_python_tree
REQ-DDB-SCHEMA-001measuredtest_unnamed_spawns_get_distinct_names → load_thread_patterns
REQ-DDB-SCHEMA-012inferredtest_unnamed_spawns_get_distinct_names → load_thread_patterns → declaration_origin
Source · 19 lines
def test_unnamed_spawns_get_distinct_names() -> None:
    """**THE FIX THAT LOOKS LIKE IT WORKED AND UNDERCOUNTS BY THREE.** `threads` is
    UNIQUE(name, entry_memberdef_rowid, kind). With a NULL entry, four lambdas sharing one
    placeholder name collapse into a single row, so the harvester would report 2 threads where
    the source has 5 — and every count downstream would be wrong while the bug report said fixed.

    The assignment target is what distinguishes them: `poller_`, `poller`, `observer`. The
    detached temporary has no target and must still differ from the others.

    @brief Unnamed spawns do not collide.
    @return None.
    @version 1
    """
    patterns = patterns_by_name(load_thread_patterns(None))
    tree, src = _parse(_LAMBDA_FORMS)

    names = [s[0] for s in _walk_spawn_sites(tree, src, patterns)]

    assert len(set(names)) == len(names), f"spawn names collide and would collapse rows: {names}"

1 more lines, not shown

Activity · 4 steps
lines 164–164patterns = patterns_by_name(load_thread_patterns(None))lines 165–165tree, src = _parse(_LAMBDA_FORMS)lines 167–167names = [s[0] for s in _walk_spawn_sites(tree, src, patterns)]lines 169–169assert len(set(names)) == len(names), f"spawn names collide and would collapse rows: {names}"