test_reference_returning_definitions_are_recovered

Tests › tests/test_ast_symbols.py

passed Passed in the packaged run.

What this test is for

Why it exists

FOUND WHILE FIXING gh#9, AND IT IS THE LARGER OF THE TWO BUGS. `_function_declarator` followed `child_by_field_name("declarator")` only, and a `reference_declarator` does NOT expose its inner declarator under that field — so the walk returned None and EVERY reference-returning definition was absent from the recovery layer whose whole job is recovering what doxygen did not emit.

Given

  1. src = ( b"#include <array>\n" b"struct Row { int a; };\n" b"static Row g_row;\n" b"static Row g_rows[4];\n" b"const std::array<Row, 4>& const_ref_return() { static std::array<Row, 4> k{}; return k; }\n" b"Row& plain_ref_return() { return g_row; }\n" b"Row* ptr_return() { return &g_row; }\n" b"int value_return() { return 1; }\n" )
  2. tree = SubstrateParser("cpp").parse(src)
→

When

  1. found = {f.name for f in harvest_function_definitions(tree, src)}
→

Then

  1. ✓ found contains "const_ref_return"
  2. ✓ found contains "plain_ref_return"
  3. ✓ found contains "ptr_return"
  4. ✓ found contains "value_return"

tests/test_ast_symbols.py:1191 · its file's page

What it checks (4)

  1. assert "const_ref_return" in found, ( f"a `const T&`-returning definition was skipped — this is the reported shape; got {found}" ) observes harvest_function_definitions via found
  2. assert "plain_ref_return" in found, f"a `T&`-returning definition was skipped; got {found}" observes harvest_function_definitions via found
  3. assert "ptr_return" in found, "pointer returns were already recovered and must remain so" observes harvest_function_definitions via found
  4. assert "value_return" in found, "plain value returns must remain so" observes harvest_function_definitions via found

Where the product reaches it

No product flow reaches this code: no product entry point's flow calls any of the functions this test calls.

Call flow

test_reference_returning_definitions_are_recovered→harvest_function_definitions

What it reaches

Each row runs from this test, through the calls it makes, to the code a requirement names. If that code breaks, the test's checks are what should catch it. Reaching is not proving: a check only proves what it observes. No mutation records were given, so these rows say what the test REACHES.

test_reference_returning_definitions_are_recovered · 4 checksharvest_function_definitionsREQ-DDB-INDEX-004 · measured
Also reaches 2 requirements

Its run touches their code; that is reach, not proof.