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

Function callable_battery

tests/repro/repro_grammar_web.c:238–300  ·  view source on GitHub ↗

── Callable battery (dims 1-6) ──────────────────────────────────────────── * * Adds dims 5 and 6 (defs-present + calls-extracted) to the base invariants. * Pass NULL for expect_label when the language has no func/class def to assert * (e.g. pure-call languages like CSS). Returns 0 on PASS, 1 on FAIL. */

Source from the content-addressed store, hash-verified

236 * (e.g. pure-call languages like CSS). Returns 0 on PASS, 1 on FAIL.
237 */
238static int callable_battery(const char *lang_tag, const char *src,
239 CBMLanguage lang, const char *file,
240 const char *expect_label, const char *callee) {
241 const char *RED = tf_red();
242 const char *RST = tf_reset();
243
244 /* 1. extract-clean */
245 if (inv_extract_clean(src, lang, file) != 1) {
246 printf(" %sFAIL%s [%s] extract-clean: NULL result or has_error set\n",
247 RED, RST, lang_tag);
248 return 1;
249 }
250
251 CBMFileResult *r = inv_rx(src, lang, file);
252 if (!r) {
253 printf(" %sFAIL%s [%s] inv_rx returned NULL after clean extract\n",
254 RED, RST, lang_tag);
255 return 1;
256 }
257
258 int fails = 0;
259
260 /* 2. labels-valid */
261 int bad_labels = inv_count_bad_labels(r);
262 if (bad_labels != 0) {
263 printf(" %sFAIL%s [%s] labels-valid: %d def(s) with invalid label\n",
264 RED, RST, lang_tag, bad_labels);
265 fails++;
266 }
267
268 /* 3. fqn-wellformed */
269 int bad_fqns = inv_count_bad_fqns(r);
270 if (bad_fqns != 0) {
271 printf(" %sFAIL%s [%s] fqn-wellformed: %d def(s) with malformed QN\n",
272 RED, RST, lang_tag, bad_fqns);
273 fails++;
274 }
275
276 /* 4. ranges-valid */
277 int bad_ranges = inv_count_bad_ranges(r);
278 if (bad_ranges != 0) {
279 printf(" %sFAIL%s [%s] ranges-valid: %d def(s) with invalid range\n",
280 RED, RST, lang_tag, bad_ranges);
281 fails++;
282 }
283
284 /* 5. defs-present (only when a def label is expected) */
285 if (expect_label && inv_count_label(r, expect_label) < 1) {
286 printf(" %sFAIL%s [%s] defs-present: no def labelled \"%s\"\n",
287 RED, RST, lang_tag, expect_label);
288 fails++;
289 }
290
291 /* 6. calls-extracted */
292 if (inv_has_call(r, callee) != 1) {
293 printf(" %sFAIL%s [%s] calls-extracted: no call to \"%s\" found\n",
294 RED, RST, lang_tag, callee);
295 fails++;

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