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

Function schema_battery

tests/repro/repro_grammar_web.c:170–230  ·  view source on GitHub ↗

── Schema/structural battery (dims 1-5) ─────────────────────────────────── * * Adds the defs-present dimension to the base battery. Used for GraphQL, * Protobuf, Thrift, and Prisma whose specs include class_types and/or * func_types. Returns 0 on PASS, 1 on FAIL. */

Source from the content-addressed store, hash-verified

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

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