Branch Coverage

include/litavis_parser.h
Criterion Covered Total %
branch 210 278 75.5


line true false branch
25 22796 0 if (pctx->pos < pctx->tokens->count)
32 6716 0 if (t->type != LITAVIS_T_EOF)
42 3690 6 if (litavis_parser_at(pctx, type)) {
52 0 2175 if (!s) LITAVIS_FATAL("out of memory");
69 974 1 if (litavis_parser_at(pctx, LITAVIS_T_VALUE)) {
87 1041 821 while (!litavis_parser_at(pctx, LITAVIS_T_RBRACE) && !litavis_parser_at(pctx, LITAVIS_T_EOF)) {
1039 2 while (!litavis_parser_at(pctx, LITAVIS_T_RBRACE) && !litavis_parser_at(pctx, LITAVIS_T_EOF)) {
90 71 968 if (type == LITAVIS_T_PROPERTY || type == LITAVIS_T_CSS_VAR_DEF) {
7 64 if (type == LITAVIS_T_PROPERTY || type == LITAVIS_T_CSS_VAR_DEF) {
92 19 45 } else if (type == LITAVIS_T_SELECTOR || type == LITAVIS_T_AMPERSAND) {
0 19 } else if (type == LITAVIS_T_SELECTOR || type == LITAVIS_T_AMPERSAND) {
95 0 19 } else if (type == LITAVIS_T_AT_KEYWORD) {
97 0 19 } else if (type == LITAVIS_T_PREPROC_VAR_DEF) {
102 0 0 if (litavis_parser_at(pctx, LITAVIS_T_VALUE)) {
112 18 1 } else if (type == LITAVIS_T_MIXIN_REF) {
119 1 0 } else if (type == LITAVIS_T_SEMICOLON) {
121 0 0 } else if (type == LITAVIS_T_COMMA) {
138 835 811 while (!litavis_parser_at(pctx, LITAVIS_T_LBRACE) && !litavis_parser_at(pctx, LITAVIS_T_EOF)) {
834 1 while (!litavis_parser_at(pctx, LITAVIS_T_LBRACE) && !litavis_parser_at(pctx, LITAVIS_T_EOF)) {
141 11 823 if (t->type == LITAVIS_T_SELECTOR || t->type == LITAVIS_T_AMPERSAND) {
0 11 if (t->type == LITAVIS_T_SELECTOR || t->type == LITAVIS_T_AMPERSAND) {
142 10 813 if (buf_pos > 0 && buf[buf_pos - 1] != ' ' && buf[buf_pos - 1] != ',') {
0 10 if (buf_pos > 0 && buf[buf_pos - 1] != ' ' && buf[buf_pos - 1] != ',') {
146 823 0 if (buf_pos + copy_len + 1 < 4096) {
152 10 1 } else if (t->type == LITAVIS_T_COMMA) {
153 10 0 if (buf_pos + 2 < 4096) {
159 0 1 } else if (t->type == LITAVIS_T_STRING) {
161 0 0 if (buf_pos + copy_len + 1 < 4096) {
173 813 0 while (buf_pos > 0 && (buf[buf_pos - 1] == ' ' || buf[buf_pos - 1] == '\t'))
0 813 while (buf_pos > 0 && (buf[buf_pos - 1] == ' ' || buf[buf_pos - 1] == '\t'))
0 813 while (buf_pos > 0 && (buf[buf_pos - 1] == ' ' || buf[buf_pos - 1] == '\t'))
185 2 811 if (!litavis_parser_match(pctx, LITAVIS_T_LBRACE)) {
190 44 767 if (parent) {
193 0 44 child->source_file = pctx->source_file ? litavis_strdup(pctx->source_file) : NULL;
199 24 743 rule->source_file = pctx->source_file ? litavis_strdup(pctx->source_file) : NULL;
215 16 0 if (litavis_parser_at(pctx, LITAVIS_T_AT_PRELUDE)) {
222 16 0 if (prelude)
227 12 4 if (litavis_parser_at(pctx, LITAVIS_T_LBRACE)) {
232 0 12 if (parent) {
238 12 0 at_rule->at_prelude = prelude ? litavis_strdup(prelude) : NULL;
239 0 12 at_rule->source_file = pctx->source_file ? litavis_strdup(pctx->source_file) : NULL;
249 0 4 if (parent) {
255 4 0 at_rule->at_prelude = prelude ? litavis_strdup(prelude) : NULL;
256 0 4 at_rule->source_file = pctx->source_file ? litavis_strdup(pctx->source_file) : NULL;
263 16 0 if (prelude) free(prelude);
269 880 584 while (!litavis_parser_at(pctx, LITAVIS_T_EOF) && !litavis_parser_at(pctx, LITAVIS_T_RBRACE)) {
877 3 while (!litavis_parser_at(pctx, LITAVIS_T_EOF) && !litavis_parser_at(pctx, LITAVIS_T_RBRACE)) {
272 109 768 if (type == LITAVIS_T_SELECTOR || type == LITAVIS_T_AMPERSAND) {
0 109 if (type == LITAVIS_T_SELECTOR || type == LITAVIS_T_AMPERSAND) {
274 16 93 } else if (type == LITAVIS_T_AT_KEYWORD) {
276 65 28 } else if (type == LITAVIS_T_PREPROC_VAR_DEF) {
281 65 0 if (litavis_parser_at(pctx, LITAVIS_T_VALUE)) {
293 23 5 } else if (type == LITAVIS_T_MIXIN_DEF) {
298 23 0 if (litavis_parser_at(pctx, LITAVIS_T_VALUE)) {
310 4 1 } else if (type == LITAVIS_T_SEMICOLON || type == LITAVIS_T_COMMA) {
0 4 } else if (type == LITAVIS_T_SEMICOLON || type == LITAVIS_T_COMMA) {
324 34 0 if (!parent || !*parent)
0 34 if (!parent || !*parent)
329 11 23 if (amp) {
334 79 11 while (*p) {
335 11 68 if (*p == '&') {
337 11 0 if (buf_pos + plen < 8192) {
343 68 0 if (buf_pos < 8191)
356 0 23 if (!combined) LITAVIS_FATAL("out of memory");
368 936 924 while (*p && count < max_out) {
936 0 while (*p && count < max_out) {
370 12 936 while (*p == ' ' || *p == '\t') p++;
0 936 while (*p == ' ' || *p == '\t') p++;
373 5646 924 while (*p) {
374 14 5632 if (*p == '(') paren_d++;
375 14 5618 else if (*p == ')') paren_d--;
376 12 5606 else if (*p == ',' && paren_d == 0) break;
12 0 else if (*p == ',' && paren_d == 0) break;
381 936 0 while (end > start && (end[-1] == ' ' || end[-1] == '\t'))
0 936 while (end > start && (end[-1] == ' ' || end[-1] == '\t'))
0 936 while (end > start && (end[-1] == ' ' || end[-1] == '\t'))
383 936 0 if (end > start) {
386 0 936 if (!s) LITAVIS_FATAL("out of memory");
391 12 924 if (*p == ',') p++;
407 30 864 if (!parent_sel || !*parent_sel) {
0 30 if (!parent_sel || !*parent_sel) {
408 873 864 for (i = 0; i < sel_count; i++)
415 32 30 for (i = 0; i < parent_count; i++) {
416 34 32 for (j = 0; j < sel_count; j++) {
420 32 30 for (i = 0; i < parent_count; i++) free(parent_parts[i]);
421 31 30 for (i = 0; i < sel_count; i++) free(selectors[i]);
425 855 39 if (rule->prop_count > 0 && !rule->is_at_rule) {
833 22 if (rule->prop_count > 0 && !rule->is_at_rule) {
429 844 833 for (i = 0; i < combined_count && jpos < 8100; i++) {
844 0 for (i = 0; i < combined_count && jpos < 8100; i++) {
430 11 833 if (i > 0) {
442 1050 833 for (i = 0; i < rule->prop_count; i++) {
445 24 809 flat_rule->source_file = rule->source_file ? litavis_strdup(rule->source_file) : NULL;
450 38 856 if (rule->is_at_rule && rule->child_count > 0) {
12 26 if (rule->is_at_rule && rule->child_count > 0) {
453 12 0 flat_at->at_prelude = rule->at_prelude ? litavis_strdup(rule->at_prelude) : NULL;
454 0 12 flat_at->source_file = rule->source_file ? litavis_strdup(rule->source_file) : NULL;
457 0 12 for (i = 0; i < rule->prop_count; i++) {
461 14 12 for (i = 0; i < rule->child_count; i++) {
465 15 14 for (ci = 0; ci < child_flat->count; ci++) {
470 0 15 if (src->source_file)
476 26 856 } else if (rule->is_at_rule) {
480 4 22 flat_at->at_prelude = rule->at_prelude ? litavis_strdup(rule->at_prelude) : NULL;
481 0 26 flat_at->source_file = rule->source_file ? litavis_strdup(rule->source_file) : NULL;
483 22 26 for (i = 0; i < rule->prop_count; i++) {
489 856 38 if (!rule->is_at_rule) {
490 30 856 for (i = 0; i < rule->child_count; i++) {
494 32 30 for (j = 0; j < combined_count && pjpos < 8100; j++) {
32 0 for (j = 0; j < combined_count && pjpos < 8100; j++) {
495 2 30 if (j > 0) {
509 30 864 if (parent_sel && *parent_sel) {
30 0 if (parent_sel && *parent_sel) {
510 34 30 for (i = 0; i < combined_count; i++)
518 850 587 for (i = 0; i < nested->count; i++) {
549 818 561 for (i = 0; i < flat->count; i++) {
554 16 802 if (src->at_prelude && !dst->at_prelude)
16 0 if (src->at_prelude && !dst->at_prelude)
556 0 818 if (src->source_file && !dst->source_file)
0 0 if (src->source_file && !dst->source_file)
558 746 72 if (src->source_line && !dst->source_line)
744 2 if (src->source_line && !dst->source_line)
562 15 818 for (j = 0; j < src->child_count; j++) {
577 1 26 if (!f) {
588 0 26 if (!buf) { fclose(f); LITAVIS_FATAL("out of memory"); }
606 38 26 for (i = 0; i < flat->count; i++) {
611 0 38 if (src->at_prelude && !dst->at_prelude)
0 0 if (src->at_prelude && !dst->at_prelude)
613 24 14 if (src->source_file && !dst->source_file)
21 3 if (src->source_file && !dst->source_file)
615 24 14 if (src->source_line && !dst->source_line)
21 3 if (src->source_line && !dst->source_line)
617 0 38 for (j = 0; j < src->child_count; j++) {
638 1 15 if (!d) {
649 60 15 while ((ent = readdir(d)) != NULL && file_count < 1024) {
60 0 while ((ent = readdir(d)) != NULL && file_count < 1024) {
651 29 31 if (nlen > 4 && strcmp(ent->d_name + nlen - 4, ".css") == 0) {
22 7 if (nlen > 4 && strcmp(ent->d_name + nlen - 4, ".css") == 0) {
654 0 22 if (!path) LITAVIS_FATAL("out of memory");
668 22 15 for (i = 0; i < file_count; i++) {