test_bare_call_one_function.py¶
tests/test_bare_call_one_function.py
A bare call to a function the index holds twice — its prototype and its definition.
test_a_bare_call_reaches_a_RECOVERED_definition
None test_bare_call_one_function.test_a_bare_call_reaches_a_RECOVERED_definition(Path tmp_path)
THE REPORTED SHAPE. doxygen saw the prototype and not the definition, so the only definition row is the one `recover_ast_symbols` wrote, spelled the way the source spells it. The call is to the one function both rows describe, and it must land on the row with the body.
tests/test_bare_call_one_function.py:148
Called by none
Calls _build, _edges_to, build_call_edges, import_ast_call_edges, recover_ast_symbols
Checks
assert recover_ast_symbols(db, repo) >= 1, "premise: the guarded definition is recovered"assert _edges_to(db, "lib_fn") == [("use_it", recovered, SOURCE_AST)]
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-INDEX-004 | measured | test_a_bare_call_reaches_a_RECOVERED_definition → recover_ast_symbols |
| REQ-DDB-PIPE-003 | measured | test_a_bare_call_reaches_a_RECOVERED_definition → build_call_edges |
| REQ-DDB-PIPE-011 | measured | test_a_bare_call_reaches_a_RECOVERED_definition → import_ast_call_edges → run_harvest → _harvest_one_file → _parseable_file |
| REQ-DDB-PIPE-012 | inferred | test_a_bare_call_reaches_a_RECOVERED_definition → import_ast_call_edges → run_harvest → _harvest_one_file → _ts_language_for → _grammar_available → has_language |
| REQ-DDB-SCHEMA-012 | measured | |
| REQ-DDB-WIKI-054 | inferred | test_a_bare_call_reaches_a_RECOVERED_definition → recover_ast_symbols → _recover_into → all |
Source · 17 lines
def test_a_bare_call_reaches_a_RECOVERED_definition(tmp_path: Path) -> None:
"""THE REPORTED SHAPE. doxygen saw the prototype and not the definition, so the only
definition row is the one `recover_ast_symbols` wrote, spelled the way the source spells it.
The call is to the one function both rows describe, and it must land on the row with the
body."""
repo, db = _build(tmp_path, _GUARDED_SOURCE, [_PROTOTYPE, _USE_IT])
assert recover_ast_symbols(db, repo) >= 1, "premise: the guarded definition is recovered"
build_call_edges(db)
import_ast_call_edges(db, repo)
conn = sqlite3.connect(str(db))
recovered = conn.execute(
"SELECT rowid FROM memberdef WHERE name = 'lib_fn' AND dg_source = 'ast'"
).fetchone()[0]
conn.close()
assert _edges_to(db, "lib_fn") == [("use_it", recovered, SOURCE_AST)]
Activity · 8 steps
test_a_bare_call_reaches_a_pair_doxygen_wrote_both_halves_of
None test_bare_call_one_function.test_a_bare_call_reaches_a_pair_doxygen_wrote_both_halves_of(Path tmp_path)
THE OTHER SHAPE. doxygen copies the definition's body range onto the header row, so both rows carry one body and one identity. The edge goes to the definition — the row whose own file holds the body.
tests/test_bare_call_one_function.py:165
Checks
assert _edges_to(db, "lib_fn") == [("use_it", 11, SOURCE_AST)]
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-PIPE-003 | measured | test_a_bare_call_reaches_a_pair_doxygen_wrote_both_halves_of → build_call_edges |
| REQ-DDB-PIPE-011 | measured | test_a_bare_call_reaches_a_pair_doxygen_wrote_both_halves_of → import_ast_call_edges → run_harvest → _harvest_one_file → _parseable_file |
| REQ-DDB-PIPE-012 | inferred | test_a_bare_call_reaches_a_pair_doxygen_wrote_both_halves_of → import_ast_call_edges → run_harvest → _harvest_one_file → _ts_language_for → _grammar_available → has_language |
| REQ-DDB-SCHEMA-012 | measured | |
| REQ-DDB-WIKI-054 | inferred | test_a_bare_call_reaches_a_pair_doxygen_wrote_both_halves_of → import_ast_call_edges → _fold_all_files → _fold_call_payload → _ast_record_call_edge → _narrow_by_receiver → _one_class → all |
Source · 12 lines
def test_a_bare_call_reaches_a_pair_doxygen_wrote_both_halves_of(tmp_path: Path) -> None:
"""THE OTHER SHAPE. doxygen copies the definition's body range onto the header row, so both
rows carry one body and one identity. The edge goes to the definition — the row whose own
file holds the body."""
definition = (11, "lib_fn", "int lib_fn", "(int a, char *b)", 2, 5, _C, _C)
header = (10, "lib_fn", "int lib_fn", "(int a, char *b)", 2, 5, _C, _H)
repo, db = _build(tmp_path, _PLAIN_SOURCE, [header, definition, _USE_IT])
build_call_edges(db)
import_ast_call_edges(db, repo)
assert _edges_to(db, "lib_fn") == [("use_it", 11, SOURCE_AST)]
Activity · 6 steps
test_a_member_call_is_not_resolved_by_the_pair_alone
None test_bare_call_one_function.test_a_member_call_is_not_resolved_by_the_pair_alone()
THE CONTROL on the source. `obj.lib_fn()` names a function of that name and says nothing about the receiver; the unverified-receiver refusal holds whether the name has one row or a decl/def pair.
tests/test_bare_call_one_function.py:251
Checks
assert targets == {(10, 11): 11}, "premise: the pair is one function"assert resolved == []
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-WIKI-054 | inferred | test_a_member_call_is_not_resolved_by_the_pair_alone → _ast_record_call_edge → _narrow_by_receiver → _one_class → all |
Source · 14 lines
def test_a_member_call_is_not_resolved_by_the_pair_alone() -> None:
"""THE CONTROL on the source. `obj.lib_fn()` names a function of that name and says nothing
about the receiver; the unverified-receiver refusal holds whether the name has one row or a
decl/def pair."""
identity = ("lib_fn", "lib_fn", "(inta,char*b)")
targets = _one_function_targets(
{"lib_fn": [10, 11]}, {10: identity, 11: identity}, {11: (2, 2)}, homes={11}
)
assert targets == {(10, 11): 11}, "premise: the pair is one function"
resolved: list[tuple[int, int, str]] = []
_ast_record_call_edge(
1, "lib_fn", {"lib_fn": [10, 11]}, resolved, [], SOURCE_AST_MEMBER, one_function=targets
)
assert resolved == []1 more lines, not shown
Activity · 6 steps
test_two_bodies_with_one_signature_are_still_refused
None test_bare_call_one_function.test_two_bodies_with_one_signature_are_still_refused()
THE CONTROL on the resolution. Two `static int helper(void)` definitions in two files share an identity and are still two functions; a name cannot say which one a call meant, so the call is refused exactly as before (gh#347) and the refusal is recorded.
tests/test_bare_call_one_function.py:224
Checks
assert targets == {}, "two bodies are two functions"assert resolved == [] and unresolved == [[30, 31]]
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-WIKI-054 | inferred | test_two_bodies_with_one_signature_are_still_refused → _ast_record_call_edge → _narrow_by_receiver → _one_class → all |
Source · 27 lines
def test_two_bodies_with_one_signature_are_still_refused() -> None:
"""THE CONTROL on the resolution. Two `static int helper(void)` definitions in two files
share an identity and are still two functions; a name cannot say which one a call meant, so
the call is refused exactly as before (gh#347) and the refusal is recorded."""
identity = ("helper", "helper", "(void)")
targets = _one_function_targets(
{"helper": [30, 31]},
{30: identity, 31: identity},
{30: (1, 10), 31: (2, 10)},
homes={30, 31},
)
assert targets == {}, "two bodies are two functions"
resolved: list[tuple[int, int, str]] = []
unresolved: list[list[int]] = []
_ast_record_call_edge(
1,
"helper",
{"helper": [30, 31]},
resolved,
[],
SOURCE_AST,
unresolved=unresolved,
one_function=targets,
)
assert resolved == [] and unresolved == [[30, 31]]