test_callback_edges_resolves_struct_literal_registration

Tests › tests/test_rust_ast.py

passed Passed in the packaged run.

What this test is for

Why it exists

The test says nothing about why.

Given

  1. tree, src = _parse( "fn handler(x: i32) -> i32 { x }\n" "struct Widget { callback: fn(i32) -> i32 }\n" "impl Widget {\n" " fn new(h: fn(i32) -> i32) -> Self {\n" " Self { callback: h }\n" " }\n" " fn fire(&self, x: i32) -> i32 {\n" " (self.callback)(x)\n" " }\n" "}\n" "fn build() -> Widget {\n" " Widget::new(handler)\n" "}\n" )
→

When

  1. out = _harvest_callback_file(tree, src)
  2. reg_globals = {r[1] for r in out["regs"]}
  3. call_names = {c[1] for c in out["calls"]}
→

Then

  1. ✓ reg_globals contains "Widget::callback"
  2. ✓ call_names contains "new"
  3. ✓ call_names contains "Widget::callback"

tests/test_rust_ast.py:201 · its file's page

What it checks (3)

  1. assert "Widget::callback" in reg_globals not attributed
  2. assert "new" in call_names not attributed
  3. assert "Widget::callback" in call_names not attributed

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_callback_edges_resolves_struct_literal_registration→_parse→_harvest_callback_file

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 1 requirement

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