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

Function config_struct_battery

tests/repro/repro_grammar_config.c:182–245  ·  view source on GitHub ↗

── Structural battery with defs-present (dims 1-5) ──────────────────────── * * Adds the defs-present dimension for languages with class_types, func_types, * or reliably-labelled var_types (TOML, INI, XML, PROPERTIES, PKL). * Pass NULL for expect_label2 when only one label type is needed. * Returns 0 on PASS, 1 on FAIL. */

Source from the content-addressed store, hash-verified

180 * Returns 0 on PASS, 1 on FAIL.
181 */
182static int config_struct_battery(const char *lang_tag, const char *src,
183 CBMLanguage lang, const char *file,
184 const char *expect_label,
185 const char *expect_label2) {
186 const char *RED = tf_red();
187 const char *RST = tf_reset();
188
189 /* 1. extract-clean */
190 if (inv_extract_clean(src, lang, file) != 1) {
191 printf(" %sFAIL%s [%s] extract-clean: NULL result or has_error set\n",
192 RED, RST, lang_tag);
193 return 1;
194 }
195
196 CBMFileResult *r = inv_rx(src, lang, file);
197 if (!r) {
198 printf(" %sFAIL%s [%s] inv_rx returned NULL after clean extract\n",
199 RED, RST, lang_tag);
200 return 1;
201 }
202
203 int fails = 0;
204
205 /* 2. labels-valid */
206 int bad_labels = inv_count_bad_labels(r);
207 if (bad_labels != 0) {
208 printf(" %sFAIL%s [%s] labels-valid: %d def(s) with invalid label\n",
209 RED, RST, lang_tag, bad_labels);
210 fails++;
211 }
212
213 /* 3. fqn-wellformed */
214 int bad_fqns = inv_count_bad_fqns(r);
215 if (bad_fqns != 0) {
216 printf(" %sFAIL%s [%s] fqn-wellformed: %d def(s) with malformed QN\n",
217 RED, RST, lang_tag, bad_fqns);
218 fails++;
219 }
220
221 /* 4. ranges-valid */
222 int bad_ranges = inv_count_bad_ranges(r);
223 if (bad_ranges != 0) {
224 printf(" %sFAIL%s [%s] ranges-valid: %d def(s) with invalid range\n",
225 RED, RST, lang_tag, bad_ranges);
226 fails++;
227 }
228
229 /* 5. defs-present (primary label) */
230 if (expect_label && inv_count_label(r, expect_label) < 1) {
231 printf(" %sFAIL%s [%s] defs-present: no def labelled \"%s\"\n",
232 RED, RST, lang_tag, expect_label);
233 fails++;
234 }
235
236 /* 5b. defs-present (secondary label, optional) */
237 if (expect_label2 && inv_count_label(r, expect_label2) < 1) {
238 printf(" %sFAIL%s [%s] defs-present: no def labelled \"%s\"\n",
239 RED, RST, lang_tag, expect_label2);

Callers 1

Calls 9

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
cbm_free_resultFunction · 0.85

Tested by

no test coverage detected