test_reference_returning_definitions_are_recovered¶
Tests › tests/test_ast_symbols.py
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
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" )tree = SubstrateParser("cpp").parse(src)
When
found = {f.name for f in harvest_function_definitions(tree, src)}
Then
- ✓ found contains "const_ref_return"
- ✓ found contains "plain_ref_return"
- ✓ found contains "ptr_return"
- ✓ found contains "value_return"
tests/test_ast_symbols.py:1191 · its file's page
What it checks (4)
assert "const_ref_return" in found, ( f"a `const T&`-returning definition was skipped — this is the reported shape; got {found}" )observesharvest_function_definitionsviafoundassert "plain_ref_return" in found, f"a `T&`-returning definition was skipped; got {found}"observesharvest_function_definitionsviafoundassert "ptr_return" in found, "pointer returns were already recovered and must remain so"observesharvest_function_definitionsviafoundassert "value_return" in found, "plain value returns must remain so"observesharvest_function_definitionsviafound
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
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.
Also reaches 2 requirements
Its run touches their code; that is reach, not proof.
- REQ-DDB-INDEX-004 measured
- REQ-DDB-PIPE-003 measured