── Structural-only battery (dims 1-4) ───────────────────────────────────── * * Runs the four base invariants that apply to EVERY language regardless of * whether it has callable or structural defs. Returns 0 on PASS, 1 on FAIL. * Used for languages whose spec has neither func_types nor class_types * (HTML, VUE, SVELTE, ASTRO, JSDoc). */
| 113 | * (HTML, VUE, SVELTE, ASTRO, JSDoc). |
| 114 | */ |
| 115 | static int structural_base_battery(const char *lang_tag, const char *src, |
| 116 | CBMLanguage lang, const char *file) { |
| 117 | const char *RED = tf_red(); |
| 118 | const char *RST = tf_reset(); |
| 119 | |
| 120 | /* 1. extract-clean */ |
| 121 | if (inv_extract_clean(src, lang, file) != 1) { |
| 122 | printf(" %sFAIL%s [%s] extract-clean: NULL result or has_error set\n", |
| 123 | RED, RST, lang_tag); |
| 124 | return 1; |
| 125 | } |
| 126 | |
| 127 | CBMFileResult *r = inv_rx(src, lang, file); |
| 128 | if (!r) { |
| 129 | printf(" %sFAIL%s [%s] inv_rx returned NULL after clean extract\n", |
| 130 | RED, RST, lang_tag); |
| 131 | return 1; |
| 132 | } |
| 133 | |
| 134 | int fails = 0; |
| 135 | |
| 136 | /* 2. labels-valid */ |
| 137 | int bad_labels = inv_count_bad_labels(r); |
| 138 | if (bad_labels != 0) { |
| 139 | printf(" %sFAIL%s [%s] labels-valid: %d def(s) with invalid label\n", |
| 140 | RED, RST, lang_tag, bad_labels); |
| 141 | fails++; |
| 142 | } |
| 143 | |
| 144 | /* 3. fqn-wellformed */ |
| 145 | int bad_fqns = inv_count_bad_fqns(r); |
| 146 | if (bad_fqns != 0) { |
| 147 | printf(" %sFAIL%s [%s] fqn-wellformed: %d def(s) with malformed QN\n", |
| 148 | RED, RST, lang_tag, bad_fqns); |
| 149 | fails++; |
| 150 | } |
| 151 | |
| 152 | /* 4. ranges-valid */ |
| 153 | int bad_ranges = inv_count_bad_ranges(r); |
| 154 | if (bad_ranges != 0) { |
| 155 | printf(" %sFAIL%s [%s] ranges-valid: %d def(s) with invalid range\n", |
| 156 | RED, RST, lang_tag, bad_ranges); |
| 157 | fails++; |
| 158 | } |
| 159 | |
| 160 | cbm_free_result(r); |
| 161 | return fails ? 1 : 0; |
| 162 | } |
| 163 | |
| 164 | /* ── Schema/structural battery (dims 1-5) ─────────────────────────────────── |
| 165 | * |
no test coverage detected