── Structural-base battery (dims 1-4) ────────────────────────────────────── * * Runs the four core invariants on valid input. No defs-present assertion. * Used for languages with no func_types/class_types and where var_types are * not reliably mapped to a named label (JSON, JSON5, YAML, CSV, KDL, RON, DOTENV). * Returns 0 on PASS, 1 on FAIL. */
| 124 | * Returns 0 on PASS, 1 on FAIL. |
| 125 | */ |
| 126 | static int config_base_battery(const char *lang_tag, const char *src, |
| 127 | CBMLanguage lang, const char *file) { |
| 128 | const char *RED = tf_red(); |
| 129 | const char *RST = tf_reset(); |
| 130 | |
| 131 | /* 1. extract-clean */ |
| 132 | if (inv_extract_clean(src, lang, file) != 1) { |
| 133 | printf(" %sFAIL%s [%s] extract-clean: NULL result or has_error set\n", |
| 134 | RED, RST, lang_tag); |
| 135 | return 1; |
| 136 | } |
| 137 | |
| 138 | CBMFileResult *r = inv_rx(src, lang, file); |
| 139 | if (!r) { |
| 140 | printf(" %sFAIL%s [%s] inv_rx returned NULL after clean extract\n", |
| 141 | RED, RST, lang_tag); |
| 142 | return 1; |
| 143 | } |
| 144 | |
| 145 | int fails = 0; |
| 146 | |
| 147 | /* 2. labels-valid */ |
| 148 | int bad_labels = inv_count_bad_labels(r); |
| 149 | if (bad_labels != 0) { |
| 150 | printf(" %sFAIL%s [%s] labels-valid: %d def(s) with invalid label\n", |
| 151 | RED, RST, lang_tag, bad_labels); |
| 152 | fails++; |
| 153 | } |
| 154 | |
| 155 | /* 3. fqn-wellformed */ |
| 156 | int bad_fqns = inv_count_bad_fqns(r); |
| 157 | if (bad_fqns != 0) { |
| 158 | printf(" %sFAIL%s [%s] fqn-wellformed: %d def(s) with malformed QN\n", |
| 159 | RED, RST, lang_tag, bad_fqns); |
| 160 | fails++; |
| 161 | } |
| 162 | |
| 163 | /* 4. ranges-valid */ |
| 164 | int bad_ranges = inv_count_bad_ranges(r); |
| 165 | if (bad_ranges != 0) { |
| 166 | printf(" %sFAIL%s [%s] ranges-valid: %d def(s) with invalid range\n", |
| 167 | RED, RST, lang_tag, bad_ranges); |
| 168 | fails++; |
| 169 | } |
| 170 | |
| 171 | cbm_free_result(r); |
| 172 | return fails ? 1 : 0; |
| 173 | } |
| 174 | |
| 175 | /* ── Structural battery with defs-present (dims 1-5) ──────────────────────── |
| 176 | * |
no test coverage detected