── Shared single-file battery: structural base (dims 1-4) ───────────────── * * Four core invariants on valid input, no defs/calls assertions. Used for the * structural-only languages (JANET, DEVICETREE, HYPRLANG). Returns 0 on PASS. */
| 127 | * structural-only languages (JANET, DEVICETREE, HYPRLANG). Returns 0 on PASS. |
| 128 | */ |
| 129 | static int sh_base_battery(const char *lang_tag, const char *src, CBMLanguage lang, |
| 130 | const char *file) { |
| 131 | const char *RED = tf_red(); |
| 132 | const char *RST = tf_reset(); |
| 133 | |
| 134 | /* 1. extract-clean */ |
| 135 | if (inv_extract_clean(src, lang, file) != 1) { |
| 136 | printf(" %sFAIL%s [%s] extract-clean: NULL result or has_error set\n", |
| 137 | RED, RST, lang_tag); |
| 138 | return 1; |
| 139 | } |
| 140 | |
| 141 | CBMFileResult *r = inv_rx(src, lang, file); |
| 142 | if (!r) { |
| 143 | printf(" %sFAIL%s [%s] inv_rx returned NULL after clean extract\n", |
| 144 | RED, RST, lang_tag); |
| 145 | return 1; |
| 146 | } |
| 147 | |
| 148 | int fails = 0; |
| 149 | |
| 150 | /* 2. labels-valid */ |
| 151 | int bad_labels = inv_count_bad_labels(r); |
| 152 | if (bad_labels != 0) { |
| 153 | printf(" %sFAIL%s [%s] labels-valid: %d def(s) with invalid label\n", |
| 154 | RED, RST, lang_tag, bad_labels); |
| 155 | fails++; |
| 156 | } |
| 157 | |
| 158 | /* 3. fqn-wellformed */ |
| 159 | int bad_fqns = inv_count_bad_fqns(r); |
| 160 | if (bad_fqns != 0) { |
| 161 | printf(" %sFAIL%s [%s] fqn-wellformed: %d def(s) with malformed QN\n", |
| 162 | RED, RST, lang_tag, bad_fqns); |
| 163 | fails++; |
| 164 | } |
| 165 | |
| 166 | /* 4. ranges-valid */ |
| 167 | int bad_ranges = inv_count_bad_ranges(r); |
| 168 | if (bad_ranges != 0) { |
| 169 | printf(" %sFAIL%s [%s] ranges-valid: %d def(s) with invalid range\n", |
| 170 | RED, RST, lang_tag, bad_ranges); |
| 171 | fails++; |
| 172 | } |
| 173 | |
| 174 | cbm_free_result(r); |
| 175 | return fails ? 1 : 0; |
| 176 | } |
| 177 | |
| 178 | /* ── Shared single-file battery: structural with defs (dims 1-5) ──────────── |
| 179 | * |
no test coverage detected