Skip to content

Commit 927dffc

Browse files
committed
test(repro): harden assert_no_resolvable_edge against vacuous pass
The 9 no-resolvable-edge tests asserted only that no CALLS edge targets the unresolvable callee via inv_no_calls_edge_to_qn, which returns PASS when the fixture produces ZERO edges for any reason — so a green did not prove the unresolvable call was actually extracted and correctly dropped (a vacuous-pass false-guard risk, unlike the sibling assert_lsp_strategy which checks callable_sourced > 0). Add an exercised-check to all four helper copies (c_cpp/java_cs/go_py/ts): require at least one callable-sourced CALLS edge. Give each of the 9 fixtures a resolvable in-fixture control call (known / Helper.Known / c.Inc) so a real edge forms. The no-edge-to-callee invariant is unchanged; the tests stay green but can no longer pass when extraction silently produces nothing. Repro board: 311 passed, 1 failed (the honest DeusData#581 RED) — no regressions. Signed-off-by: Martin Vogel <martin.vogel.tech@gmail.com>
1 parent 25d2fa8 commit 927dffc

4 files changed

Lines changed: 90 additions & 27 deletions

File tree

‎tests/repro/repro_lsp_c_cpp.c‎

Lines changed: 25 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,21 @@ static int assert_no_resolvable_edge(const char *filename, const char *src,
156156
return 1;
157157
}
158158
int rc = 0;
159+
/* Exercised-check: the fixture MUST produce at least one callable-sourced
160+
* CALLS edge (its in-fixture control call). Without it the "no edge to
161+
* <callee>" invariant is VACUOUS — it also passes when extraction silently
162+
* produced nothing, so a green would not prove the unresolvable call was
163+
* actually processed and correctly dropped. */
164+
int module_sourced = -1;
165+
int callable_sourced = -1;
166+
inv_count_calls_by_source(store, lp.project, &module_sourced, &callable_sourced);
167+
(void)module_sourced;
168+
if (callable_sourced <= 0) {
169+
printf(" %sFAIL%s %s:%d: no callable-sourced CALLS edge — fixture not "
170+
"exercised; the no-edge invariant for %s is vacuous\n",
171+
tf_red(), tf_reset(), __FILE__, __LINE__, callee_substr);
172+
rc = 1;
173+
}
159174
if (!inv_no_calls_edge_to_qn(store, lp.project, callee_substr)) {
160175
printf(" %sFAIL%s %s:%d: a CALLS edge unexpectedly targets %s "
161176
"(expected NONE — callee is unresolvable)\n",
@@ -302,12 +317,12 @@ static const char kFuncPtr[] =
302317
* (RED) — it documents that the DLL-resolution path needs an external binding
303318
* the single-file harness can't synthesize. The fixture below at least exercises
304319
* a pointer assigned from an extern declaration. */
305-
static const char kDllResolve[] =
306-
"extern int plugin_entry(int x);\n"
307-
"int caller(int v) {\n"
308-
" int (*fp)(int) = plugin_entry;\n"
309-
" return fp(v);\n"
310-
"}\n";
320+
static const char kDllResolve[] = "extern int plugin_entry(int x);\n"
321+
"int known(int x) { return x + 1; }\n"
322+
"int caller(int v) {\n"
323+
" int (*fp)(int) = plugin_entry;\n"
324+
" return known(v) + fp(v);\n"
325+
"}\n";
311326

312327
/* lsp_operator — overloaded binary operator+ on a custom type (c_lsp.c:3771-3789:
313328
* binary_expression, lhs is a custom type, operator+ member found). */
@@ -387,10 +402,10 @@ static const char kAdl[] =
387402
* called with a NULL callee_qn; the more common unresolved path is
388403
* c_emit_unresolved_call (a different marker). This fixture exercises a call to
389404
* an undeclared function and documents whether "lsp_unresolved" surfaces. */
390-
static const char kUnresolved[] =
391-
"int caller(int v) {\n"
392-
" return totally_unknown_fn(v);\n"
393-
"}\n";
405+
static const char kUnresolved[] = "int known(int x) { return x + 1; }\n"
406+
"int caller(int v) {\n"
407+
" return known(v) + totally_unknown_fn(v);\n"
408+
"}\n";
394409

395410
/* ── Per-strategy tests ──────────────────────────────────────────────────── */
396411

‎tests/repro/repro_lsp_go_py.c‎

Lines changed: 27 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,21 @@ static int assert_no_resolvable_edge_files(const RFile *files, int nfiles,
201201
return 1;
202202
}
203203
int rc = 0;
204+
/* Exercised-check: the fixture MUST produce at least one callable-sourced
205+
* CALLS edge (its in-fixture control call). Without it the "no edge to
206+
* <callee>" invariant is VACUOUS — it also passes when extraction silently
207+
* produced nothing, so a green would not prove the unresolvable call was
208+
* actually processed and correctly dropped. */
209+
int module_sourced = -1;
210+
int callable_sourced = -1;
211+
inv_count_calls_by_source(store, lp.project, &module_sourced, &callable_sourced);
212+
(void)module_sourced;
213+
if (callable_sourced <= 0) {
214+
printf(" %sFAIL%s %s:%d: no callable-sourced CALLS edge — fixture not "
215+
"exercised; the no-edge invariant for %s is vacuous\n",
216+
tf_red(), tf_reset(), __FILE__, __LINE__, callee_substr);
217+
rc = 1;
218+
}
204219
if (!inv_no_calls_edge_to_qn(store, lp.project, callee_substr)) {
205220
printf(" %sFAIL%s %s:%d: a CALLS edge unexpectedly targets %s "
206221
"(expected NONE — callee is unresolvable)\n",
@@ -309,11 +324,11 @@ static const RFile kGoCrossFile[] = {
309324
* "lsp_unresolved"). NOTE: emit_unresolved_call uses confidence 0.0, so the
310325
* pipeline may not promote it into a CALLS edge with the strategy tag — this
311326
* fixture documents whether "lsp_unresolved" surfaces in the graph. */
312-
static const char kGoUnresolved[] =
313-
"package main\n"
314-
"func caller(v int) int {\n"
315-
" return totallyUnknownFn(v)\n"
316-
"}\n";
327+
static const char kGoUnresolved[] = "package main\n"
328+
"func known(x int) int { return x + 1 }\n"
329+
"func caller(v int) int {\n"
330+
" return known(v) + totallyUnknownFn(v)\n"
331+
"}\n";
317332

318333
/* ── Python fixtures ───────────────────────────────────────────────────────── */
319334

@@ -386,13 +401,13 @@ static const RFile kPyModuleAttr[] = {
386401
* symbol lookup misses → best-effort "module.attr" QN, low confidence). helpers
387402
* defines nothing named missing_fn. */
388403
static const RFile kPyModuleAttrUnresolved[] = {
389-
{"helpers.py",
390-
"def do_work(x):\n"
391-
" return x + 9\n"},
392-
{"main.py",
393-
"import helpers\n"
394-
"def caller(v):\n"
395-
" return helpers.missing_fn(v)\n"},
404+
{"helpers.py", "def do_work(x):\n"
405+
" return x + 9\n"},
406+
{"main.py", "import helpers\n"
407+
"def known(x):\n"
408+
" return x + 1\n"
409+
"def caller(v):\n"
410+
" return known(v) + helpers.missing_fn(v)\n"},
396411
};
397412

398413
/* lsp_dict_dispatch — funcs["key"]() where funcs is a dict-literal dispatch

‎tests/repro/repro_lsp_java_cs.c‎

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,21 @@ static int assert_no_resolvable_edge(const char *filename, const char *src,
174174
return 1;
175175
}
176176
int rc = 0;
177+
/* Exercised-check: the fixture MUST produce at least one callable-sourced
178+
* CALLS edge (its in-fixture control call). Without it the "no edge to
179+
* <callee>" invariant is VACUOUS — it also passes when extraction silently
180+
* produced nothing, so a green would not prove the unresolvable call was
181+
* actually processed and correctly dropped. */
182+
int module_sourced = -1;
183+
int callable_sourced = -1;
184+
inv_count_calls_by_source(store, lp.project, &module_sourced, &callable_sourced);
185+
(void)module_sourced;
186+
if (callable_sourced <= 0) {
187+
printf(" %sFAIL%s %s:%d: no callable-sourced CALLS edge — fixture not "
188+
"exercised; the no-edge invariant for %s is vacuous\n",
189+
tf_red(), tf_reset(), __FILE__, __LINE__, callee_substr);
190+
rc = 1;
191+
}
177192
if (!inv_no_calls_edge_to_qn(store, lp.project, callee_substr)) {
178193
printf(" %sFAIL%s %s:%d: a CALLS edge unexpectedly targets %s "
179194
"(expected NONE — callee is unresolvable)\n",
@@ -245,7 +260,8 @@ static const char kJavaStaticImport[] =
245260
static const char kJavaStaticImportText[] =
246261
"import static java.lang.Math.max;\n"
247262
"class Client {\n"
248-
" int run(int a, int b) { return max(a, b); }\n"
263+
" int known(int x) { return x + 1; }\n"
264+
" int run(int a, int b) { return known(a) + max(a, b); }\n"
249265
"}\n";
250266

251267
/* lsp_super_dispatch — super.method() resolves on the superclass
@@ -375,7 +391,8 @@ static const char kJavaConstructorSynth[] =
375391
* surfaces on a CALLS edge at all. */
376392
static const char kJavaUnresolved[] =
377393
"class Client {\n"
378-
" int run(int v) { return totallyUnknownFn(v); }\n"
394+
" int known(int x) { return x + 1; }\n"
395+
" int run(int v) { return known(v) + totallyUnknownFn(v); }\n"
379396
"}\n";
380397

381398
/* ── C# fixtures ─────────────────────────────────────────────────────────────
@@ -402,7 +419,7 @@ static const char kCsStaticTypedUnindexed[] =
402419
" public static int Known() { return 1; }\n"
403420
"}\n"
404421
"class Client {\n"
405-
" public int Run() { return Helper.Missing(); }\n"
422+
" public int Run() { return Helper.Known() + Helper.Missing(); }\n"
406423
"}\n";
407424

408425
/* cs_method_typed — obj.Method() on the object's OWN declared type
@@ -450,7 +467,7 @@ static const char kCsMethodTypedUnindexed[] =
450467
" public int Inc(int x) { return x + 1; }\n"
451468
"}\n"
452469
"class Client {\n"
453-
" public int Run(Counter c) { return c.Missing(); }\n"
470+
" public int Run(Counter c) { return c.Inc(1) + c.Missing(); }\n"
454471
"}\n";
455472

456473
/* cs_self_method — a bare Method() resolved on the enclosing class

‎tests/repro/repro_lsp_ts.c‎

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,21 @@ static int assert_no_resolvable_edge(const char *filename, const char *src,
193193
return 1;
194194
}
195195
int rc = 0;
196+
/* Exercised-check: the fixture MUST produce at least one callable-sourced
197+
* CALLS edge (its in-fixture control call). Without it the "no edge to
198+
* <callee>" invariant is VACUOUS — it also passes when extraction silently
199+
* produced nothing, so a green would not prove the unresolvable call was
200+
* actually processed and correctly dropped. */
201+
int module_sourced = -1;
202+
int callable_sourced = -1;
203+
inv_count_calls_by_source(store, lp.project, &module_sourced, &callable_sourced);
204+
(void)module_sourced;
205+
if (callable_sourced <= 0) {
206+
printf(" %sFAIL%s %s:%d: no callable-sourced CALLS edge — fixture not "
207+
"exercised; the no-edge invariant for %s is vacuous\n",
208+
tf_red(), tf_reset(), __FILE__, __LINE__, callee_substr);
209+
rc = 1;
210+
}
196211
if (!inv_no_calls_edge_to_qn(store, lp.project, callee_substr)) {
197212
printf(" %sFAIL%s %s:%d: a CALLS edge unexpectedly targets %s "
198213
"(expected NONE — callee is unresolvable)\n",
@@ -333,7 +348,8 @@ static const char kTsDefault[] =
333348
* is EXPECTED ABSENT (RED) — it documents whether "lsp_unresolved" surfaces in
334349
* the graph. */
335350
static const char kTsUnresolved[] =
336-
"function caller(v: number): number { return totallyUnknownFn(v); }\n";
351+
"function known(x: number): number { return x + 1; }\n"
352+
"function caller(v: number): number { return known(v) + totallyUnknownFn(v); }\n";
337353

338354
/* ── Per-strategy tests ──────────────────────────────────────────────────── */
339355

0 commit comments

Comments
 (0)