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

Function markup_struct_battery

tests/repro/repro_grammar_markup.c:214–277  ·  view source on GitHub ↗

-- Structural battery with defs-present (dims 1-5) ------------------------ * * Adds the defs-present dimension for languages with def-minting types * (MARKDOWN, CAPNP, SMITHY, WIT). 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

212 * label type is needed. Returns 0 on PASS, 1 on FAIL.
213 */
214static int markup_struct_battery(const char *lang_tag, const char *src,
215 CBMLanguage lang, const char *file,
216 const char *expect_label,
217 const char *expect_label2) {
218 const char *RED = tf_red();
219 const char *RST = tf_reset();
220
221 /* 1. extract-clean */
222 if (inv_extract_clean(src, lang, file) != 1) {
223 printf(" %sFAIL%s [%s] extract-clean: NULL result or has_error set\n",
224 RED, RST, lang_tag);
225 return 1;
226 }
227
228 CBMFileResult *r = inv_rx(src, lang, file);
229 if (!r) {
230 printf(" %sFAIL%s [%s] inv_rx returned NULL after clean extract\n",
231 RED, RST, lang_tag);
232 return 1;
233 }
234
235 int fails = 0;
236
237 /* 2. labels-valid */
238 int bad_labels = inv_count_bad_labels(r);
239 if (bad_labels != 0) {
240 printf(" %sFAIL%s [%s] labels-valid: %d def(s) with invalid label\n",
241 RED, RST, lang_tag, bad_labels);
242 fails++;
243 }
244
245 /* 3. fqn-wellformed */
246 int bad_fqns = inv_count_bad_fqns(r);
247 if (bad_fqns != 0) {
248 printf(" %sFAIL%s [%s] fqn-wellformed: %d def(s) with malformed QN\n",
249 RED, RST, lang_tag, bad_fqns);
250 fails++;
251 }
252
253 /* 4. ranges-valid */
254 int bad_ranges = inv_count_bad_ranges(r);
255 if (bad_ranges != 0) {
256 printf(" %sFAIL%s [%s] ranges-valid: %d def(s) with invalid range\n",
257 RED, RST, lang_tag, bad_ranges);
258 fails++;
259 }
260
261 /* 5. defs-present (primary label) */
262 if (expect_label && inv_count_label(r, expect_label) < 1) {
263 printf(" %sFAIL%s [%s] defs-present: no def labelled \"%s\"\n",
264 RED, RST, lang_tag, expect_label);
265 fails++;
266 }
267
268 /* 5b. defs-present (secondary label, optional) */
269 if (expect_label2 && inv_count_label(r, expect_label2) < 1) {
270 printf(" %sFAIL%s [%s] defs-present: no def labelled \"%s\"\n",
271 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