-- Structural-base battery (dims 1-4) ------------------------------------- * * Runs the four core invariants on valid input. No defs-present assertion. * Used for languages with no def-minting types (RST, MERMAID, PO, DIFF, REGEX, * BIBTEX, LIQUID, JINJA2, BLADE, SOQL, SOSL). Returns 0 on PASS, 1 on FAIL. */
| 157 | * BIBTEX, LIQUID, JINJA2, BLADE, SOQL, SOSL). Returns 0 on PASS, 1 on FAIL. |
| 158 | */ |
| 159 | static int markup_base_battery(const char *lang_tag, const char *src, |
| 160 | CBMLanguage lang, const char *file) { |
| 161 | const char *RED = tf_red(); |
| 162 | const char *RST = tf_reset(); |
| 163 | |
| 164 | /* 1. extract-clean */ |
| 165 | if (inv_extract_clean(src, lang, file) != 1) { |
| 166 | printf(" %sFAIL%s [%s] extract-clean: NULL result or has_error set\n", |
| 167 | RED, RST, lang_tag); |
| 168 | return 1; |
| 169 | } |
| 170 | |
| 171 | CBMFileResult *r = inv_rx(src, lang, file); |
| 172 | if (!r) { |
| 173 | printf(" %sFAIL%s [%s] inv_rx returned NULL after clean extract\n", |
| 174 | RED, RST, lang_tag); |
| 175 | return 1; |
| 176 | } |
| 177 | |
| 178 | int fails = 0; |
| 179 | |
| 180 | /* 2. labels-valid */ |
| 181 | int bad_labels = inv_count_bad_labels(r); |
| 182 | if (bad_labels != 0) { |
| 183 | printf(" %sFAIL%s [%s] labels-valid: %d def(s) with invalid label\n", |
| 184 | RED, RST, lang_tag, bad_labels); |
| 185 | fails++; |
| 186 | } |
| 187 | |
| 188 | /* 3. fqn-wellformed */ |
| 189 | int bad_fqns = inv_count_bad_fqns(r); |
| 190 | if (bad_fqns != 0) { |
| 191 | printf(" %sFAIL%s [%s] fqn-wellformed: %d def(s) with malformed QN\n", |
| 192 | RED, RST, lang_tag, bad_fqns); |
| 193 | fails++; |
| 194 | } |
| 195 | |
| 196 | /* 4. ranges-valid */ |
| 197 | int bad_ranges = inv_count_bad_ranges(r); |
| 198 | if (bad_ranges != 0) { |
| 199 | printf(" %sFAIL%s [%s] ranges-valid: %d def(s) with invalid range\n", |
| 200 | RED, RST, lang_tag, bad_ranges); |
| 201 | fails++; |
| 202 | } |
| 203 | |
| 204 | cbm_free_result(r); |
| 205 | return fails ? 1 : 0; |
| 206 | } |
| 207 | |
| 208 | /* -- Structural battery with defs-present (dims 1-5) ------------------------ |
| 209 | * |
no test coverage detected