MCPcopy Create free account
hub / github.com/DeusData/codebase-memory-mcp / build_callable_battery

Function build_callable_battery

tests/repro/repro_grammar_build.c:259–322  ·  view source on GitHub ↗

── Callable battery (dims 1-6) ───────────────────────────────────────────── * * Adds dims 5 (optional) and 6 (calls-extracted) to the base invariants. * Pass NULL for expect_label when the language has no func/class def to assert * alongside the call (e.g. GN has call_types but no func_types). * Returns 0 on PASS, 1 on FAIL. */

Source from the content-addressed store, hash-verified

257 * Returns 0 on PASS, 1 on FAIL.
258 */
259static int build_callable_battery(const char *lang_tag, const char *src,
260 CBMLanguage lang, const char *file,
261 const char *expect_label,
262 const char *callee) {
263 const char *RED = tf_red();
264 const char *RST = tf_reset();
265
266 /* 1. extract-clean */
267 if (inv_extract_clean(src, lang, file) != 1) {
268 printf(" %sFAIL%s [%s] extract-clean: NULL result or has_error set\n",
269 RED, RST, lang_tag);
270 return 1;
271 }
272
273 CBMFileResult *r = inv_rx(src, lang, file);
274 if (!r) {
275 printf(" %sFAIL%s [%s] inv_rx returned NULL after clean extract\n",
276 RED, RST, lang_tag);
277 return 1;
278 }
279
280 int fails = 0;
281
282 /* 2. labels-valid */
283 int bad_labels = inv_count_bad_labels(r);
284 if (bad_labels != 0) {
285 printf(" %sFAIL%s [%s] labels-valid: %d def(s) with invalid label\n",
286 RED, RST, lang_tag, bad_labels);
287 fails++;
288 }
289
290 /* 3. fqn-wellformed */
291 int bad_fqns = inv_count_bad_fqns(r);
292 if (bad_fqns != 0) {
293 printf(" %sFAIL%s [%s] fqn-wellformed: %d def(s) with malformed QN\n",
294 RED, RST, lang_tag, bad_fqns);
295 fails++;
296 }
297
298 /* 4. ranges-valid */
299 int bad_ranges = inv_count_bad_ranges(r);
300 if (bad_ranges != 0) {
301 printf(" %sFAIL%s [%s] ranges-valid: %d def(s) with invalid range\n",
302 RED, RST, lang_tag, bad_ranges);
303 fails++;
304 }
305
306 /* 5. defs-present (only when a def label is expected) */
307 if (expect_label && inv_count_label(r, expect_label) < 1) {
308 printf(" %sFAIL%s [%s] defs-present: no def labelled \"%s\"\n",
309 RED, RST, lang_tag, expect_label);
310 fails++;
311 }
312
313 /* 6. calls-extracted */
314 if (callee && inv_has_call(r, callee) != 1) {
315 printf(" %sFAIL%s [%s] calls-extracted: no call to \"%s\" found\n",
316 RED, RST, lang_tag, callee);

Callers 1

Calls 10

tf_redFunction · 0.85
tf_resetFunction · 0.85
inv_extract_cleanFunction · 0.85
inv_rxFunction · 0.85
inv_count_bad_labelsFunction · 0.85
inv_count_bad_fqnsFunction · 0.85
inv_count_bad_rangesFunction · 0.85
inv_count_labelFunction · 0.85
inv_has_callFunction · 0.85
cbm_free_resultFunction · 0.85

Tested by

no test coverage detected