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

Function single_file_battery

tests/repro/repro_grammar_scripting.c:106–173  ·  view source on GitHub ↗

── Shared single-file battery (dimensions 1-6) ──────────────────────────── * * Runs the six single-file invariants against one fixture. Returns 0 when all * pass, 1 otherwise (printing a per-dimension FAIL line). lang_tag is for * diagnostics only. expect_label / expect_label2 are def labels the fixture is * guaranteed to produce (e.g. "Function" and "Class"); pass NULL for * expect_label2

Source from the content-addressed store, hash-verified

104 * in-body callee name that must appear in the extracted calls.
105 */
106static int single_file_battery(const char *lang_tag, const char *src,
107 CBMLanguage lang, const char *file,
108 const char *expect_label,
109 const char *expect_label2, const char *callee) {
110 const char *RED = tf_red();
111 const char *RST = tf_reset();
112 int fails = 0;
113
114 /* 1. extract-clean -- must hold before anything else is meaningful. */
115 if (inv_extract_clean(src, lang, file) != 1) {
116 printf(" %sFAIL%s [%s] extract-clean: NULL result or has_error set\n",
117 RED, RST, lang_tag);
118 return 1; /* nothing else can be trusted */
119 }
120
121 CBMFileResult *r = inv_rx(src, lang, file);
122 if (!r) {
123 printf(" %sFAIL%s [%s] inv_rx returned NULL after clean extract\n",
124 RED, RST, lang_tag);
125 return 1;
126 }
127
128 /* 2. labels-valid */
129 int bad_labels = inv_count_bad_labels(r);
130 if (bad_labels != 0) {
131 printf(" %sFAIL%s [%s] labels-valid: %d def(s) with invalid label\n",
132 RED, RST, lang_tag, bad_labels);
133 fails++;
134 }
135
136 /* 3. fqn-wellformed */
137 int bad_fqns = inv_count_bad_fqns(r);
138 if (bad_fqns != 0) {
139 printf(" %sFAIL%s [%s] fqn-wellformed: %d def(s) with malformed QN\n",
140 RED, RST, lang_tag, bad_fqns);
141 fails++;
142 }
143
144 /* 4. ranges-valid */
145 int bad_ranges = inv_count_bad_ranges(r);
146 if (bad_ranges != 0) {
147 printf(" %sFAIL%s [%s] ranges-valid: %d def(s) with invalid range\n",
148 RED, RST, lang_tag, bad_ranges);
149 fails++;
150 }
151
152 /* 5. defs-present -- the function/class the fixture wrote must be extracted. */
153 if (expect_label && inv_count_label(r, expect_label) < 1) {
154 printf(" %sFAIL%s [%s] defs-present: no def labelled \"%s\"\n",
155 RED, RST, lang_tag, expect_label);
156 fails++;
157 }
158 if (expect_label2 && inv_count_label(r, expect_label2) < 1) {
159 printf(" %sFAIL%s [%s] defs-present: no def labelled \"%s\"\n",
160 RED, RST, lang_tag, expect_label2);
161 fails++;
162 }
163

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