From 4cf5dabd31c1c0bba54b36790d4068c39e2ce7d9 Mon Sep 17 00:00:00 2001 From: "Rafael G. Martins" Date: Wed, 21 Feb 2018 18:49:24 +0100 Subject: blogc: template parser refactoring mostly names and data structures. --- tests/blogc/check_loader.c | 2 +- tests/blogc/check_renderer.c | 48 +-- tests/blogc/check_template_parser.c | 730 ++++++++++++++++++------------------ 3 files changed, 390 insertions(+), 390 deletions(-) (limited to 'tests') diff --git a/tests/blogc/check_loader.c b/tests/blogc/check_loader.c index ec82af1..504b296 100644 --- a/tests/blogc/check_loader.c +++ b/tests/blogc/check_loader.c @@ -75,7 +75,7 @@ test_template_parse_from_file(void **state) assert_null(err); assert_non_null(l); assert_int_equal(bc_slist_length(l), 2); - blogc_template_free_stmts(l); + blogc_template_free_ast(l); } diff --git a/tests/blogc/check_renderer.c b/tests/blogc/check_renderer.c index 327a42b..b0fbb94 100644 --- a/tests/blogc/check_renderer.c +++ b/tests/blogc/check_renderer.c @@ -101,7 +101,7 @@ test_render_entry(void **state) "LOL4\n" "lol foo haha lol bar haha lol baz haha \n" "\n"); - blogc_template_free_stmts(l); + blogc_template_free_ast(l); bc_slist_free_full(s, (bc_free_func_t) bc_trie_free); free(out); } @@ -150,7 +150,7 @@ test_render_listing(void **state) "\n" "\n" "\n"); - blogc_template_free_stmts(l); + blogc_template_free_ast(l); bc_slist_free_full(s, (bc_free_func_t) bc_trie_free); free(out); } @@ -181,7 +181,7 @@ test_render_listing_empty(void **state) "fuuu\n" "\n" "\n"); - blogc_template_free_stmts(l); + blogc_template_free_ast(l); free(out); } @@ -209,7 +209,7 @@ test_render_ifdef(void **state) "\n" "\n" "\n"); - blogc_template_free_stmts(l); + blogc_template_free_ast(l); bc_slist_free_full(s, (bc_free_func_t) bc_trie_free); free(out); } @@ -240,7 +240,7 @@ test_render_ifdef2(void **state) "\n" "\n" "\n"); - blogc_template_free_stmts(l); + blogc_template_free_ast(l); bc_slist_free_full(s, (bc_free_func_t) bc_trie_free); free(out); } @@ -273,7 +273,7 @@ test_render_ifdef3(void **state) "\n" "\n" "\n"); - blogc_template_free_stmts(l); + blogc_template_free_ast(l); bc_slist_free_full(s, (bc_free_func_t) bc_trie_free); free(out); } @@ -309,7 +309,7 @@ test_render_ifdef4(void **state) "\n" "\n" "\n"); - blogc_template_free_stmts(l); + blogc_template_free_ast(l); bc_slist_free_full(s, (bc_free_func_t) bc_trie_free); free(out); } @@ -343,7 +343,7 @@ test_render_ifdef5(void **state) "\n" "\n" "\n"); - blogc_template_free_stmts(l); + blogc_template_free_ast(l); bc_slist_free_full(s, (bc_free_func_t) bc_trie_free); free(out); } @@ -375,7 +375,7 @@ test_render_ifdef6(void **state) "lol\n" "\n" "\n"); - blogc_template_free_stmts(l); + blogc_template_free_ast(l); bc_slist_free_full(s, (bc_free_func_t) bc_trie_free); free(out); } @@ -413,7 +413,7 @@ test_render_ifdef7(void **state) "\n" "\n" "\n"); - blogc_template_free_stmts(l); + blogc_template_free_ast(l); bc_slist_free_full(s, (bc_free_func_t) bc_trie_free); free(out); } @@ -448,7 +448,7 @@ test_render_ifndef(void **state) "\n" "\n" "\n"); - blogc_template_free_stmts(l); + blogc_template_free_ast(l); bc_slist_free_full(s, (bc_free_func_t) bc_trie_free); free(out); } @@ -485,7 +485,7 @@ test_render_if_eq(void **state) "\n" "\n" "\n"); - blogc_template_free_stmts(l); + blogc_template_free_ast(l); bc_slist_free_full(s, (bc_free_func_t) bc_trie_free); free(out); } @@ -522,7 +522,7 @@ test_render_if_neq(void **state) "\n" "\n" "\n"); - blogc_template_free_stmts(l); + blogc_template_free_ast(l); bc_slist_free_full(s, (bc_free_func_t) bc_trie_free); free(out); } @@ -559,7 +559,7 @@ test_render_if_lt(void **state) "\n" "\n" "\n"); - blogc_template_free_stmts(l); + blogc_template_free_ast(l); bc_slist_free_full(s, (bc_free_func_t) bc_trie_free); free(out); } @@ -596,7 +596,7 @@ test_render_if_gt(void **state) "\n" "\n" "\n"); - blogc_template_free_stmts(l); + blogc_template_free_ast(l); bc_slist_free_full(s, (bc_free_func_t) bc_trie_free); free(out); } @@ -637,7 +637,7 @@ test_render_if_lt_eq(void **state) "\n" "\n" "\n"); - blogc_template_free_stmts(l); + blogc_template_free_ast(l); bc_slist_free_full(s, (bc_free_func_t) bc_trie_free); free(out); } @@ -678,7 +678,7 @@ test_render_if_gt_eq(void **state) "\n" "\n" "\n"); - blogc_template_free_stmts(l); + blogc_template_free_ast(l); bc_slist_free_full(s, (bc_free_func_t) bc_trie_free); free(out); } @@ -702,7 +702,7 @@ test_render_foreach(void **state) "\n" " foo bar baz \n" "\n"); - blogc_template_free_stmts(l); + blogc_template_free_ast(l); bc_slist_free_full(s, (bc_free_func_t) bc_trie_free); free(out); } @@ -727,7 +727,7 @@ test_render_foreach_if(void **state) "\n" " bar \n" "\n"); - blogc_template_free_stmts(l); + blogc_template_free_ast(l); bc_slist_free_full(s, (bc_free_func_t) bc_trie_free); free(out); } @@ -753,7 +753,7 @@ test_render_foreach_if_else(void **state) "\n" "foo yay baz \n" "\n"); - blogc_template_free_stmts(l); + blogc_template_free_ast(l); bc_slist_free_full(s, (bc_free_func_t) bc_trie_free); free(out); } @@ -787,7 +787,7 @@ test_render_outside_block(void **state) "\n" "lol\n"); bc_trie_free(c); - blogc_template_free_stmts(l); + blogc_template_free_ast(l); bc_slist_free_full(s, (bc_free_func_t) bc_trie_free); free(out); } @@ -826,7 +826,7 @@ test_render_prefer_local_variable(void **state) "\n" "\n"); bc_trie_free(c); - blogc_template_free_stmts(l); + blogc_template_free_ast(l); bc_slist_free_full(s, (bc_free_func_t) bc_trie_free); free(out); } @@ -858,7 +858,7 @@ test_render_respect_variable_scope(void **state) "asd\n" "\n"); bc_trie_free(c); - blogc_template_free_stmts(l); + blogc_template_free_ast(l); bc_slist_free_full(s, (bc_free_func_t) bc_trie_free); free(out); } @@ -889,7 +889,7 @@ test_render_ifcount_bug(void **state) "\n" "\n"); bc_trie_free(c); - blogc_template_free_stmts(l); + blogc_template_free_ast(l); bc_slist_free_full(s, (bc_free_func_t) bc_trie_free); free(out); } diff --git a/tests/blogc/check_template_parser.c b/tests/blogc/check_template_parser.c index afc42f2..a6d9034 100644 --- a/tests/blogc/check_template_parser.c +++ b/tests/blogc/check_template_parser.c @@ -17,27 +17,27 @@ static void -blogc_assert_template_stmt(bc_slist_t *l, const char *value, - const blogc_template_stmt_type_t type) +blogc_assert_template_node(bc_slist_t *l, const char *data, + const blogc_template_node_type_t type) { - blogc_template_stmt_t *stmt = l->data; - if (value == NULL) - assert_null(stmt->value); + blogc_template_node_t *node = l->data; + if (data == NULL) + assert_null(node->data[0]); else - assert_string_equal(stmt->value, value); - assert_int_equal(stmt->type, type); + assert_string_equal(node->data[0], data); + assert_int_equal(node->type, type); } static void -blogc_assert_template_if_stmt(bc_slist_t *l, const char *variable, - blogc_template_stmt_operator_t operator, const char *operand) +blogc_assert_template_if_node(bc_slist_t *l, const char *variable, + blogc_template_operator_t operator, const char *operand) { - blogc_template_stmt_t *stmt = l->data; - assert_string_equal(stmt->value, variable); - assert_int_equal(stmt->op, operator); - assert_string_equal(stmt->value2, operand); - assert_int_equal(stmt->type, BLOGC_TEMPLATE_IF_STMT); + blogc_template_node_t *node = l->data; + assert_string_equal(node->data[0], variable); + assert_int_equal(node->op, operator); + assert_string_equal(node->data[1], operand); + assert_int_equal(node->type, BLOGC_TEMPLATE_NODE_IF); } @@ -60,68 +60,68 @@ test_template_parse(void **state) "{%- foreach BOLA %}hahaha{% endforeach %}\n" "{% if BOLA == \"1\\\"0\" %}aee{% else %}fffuuuuuuu{% endif %}"; bc_error_t *err = NULL; - bc_slist_t *stmts = blogc_template_parse(a, strlen(a), &err); + bc_slist_t *ast = blogc_template_parse(a, strlen(a), &err); assert_null(err); - assert_non_null(stmts); - blogc_assert_template_stmt(stmts, "Test", - BLOGC_TEMPLATE_CONTENT_STMT); - blogc_assert_template_stmt(stmts->next, "entry", - BLOGC_TEMPLATE_BLOCK_STMT); - blogc_assert_template_stmt(stmts->next->next, "", - BLOGC_TEMPLATE_CONTENT_STMT); - blogc_assert_template_stmt(stmts->next->next->next, "CHUNDA", - BLOGC_TEMPLATE_IFDEF_STMT); - blogc_assert_template_stmt(stmts->next->next->next->next, "\nbola\n", - BLOGC_TEMPLATE_CONTENT_STMT); - blogc_assert_template_stmt(stmts->next->next->next->next->next, NULL, - BLOGC_TEMPLATE_ENDIF_STMT); - blogc_assert_template_stmt(stmts->next->next->next->next->next->next, "\n", - BLOGC_TEMPLATE_CONTENT_STMT); - bc_slist_t *tmp = stmts->next->next->next->next->next->next->next; - blogc_assert_template_stmt(tmp, "BOLA", BLOGC_TEMPLATE_IFNDEF_STMT); - blogc_assert_template_stmt(tmp->next, "\nbolao", BLOGC_TEMPLATE_CONTENT_STMT); - blogc_assert_template_stmt(tmp->next->next, NULL, BLOGC_TEMPLATE_ENDIF_STMT); - blogc_assert_template_stmt(tmp->next->next->next, "\n", - BLOGC_TEMPLATE_CONTENT_STMT); + assert_non_null(ast); + blogc_assert_template_node(ast, "Test", + BLOGC_TEMPLATE_NODE_CONTENT); + blogc_assert_template_node(ast->next, "entry", + BLOGC_TEMPLATE_NODE_BLOCK); + blogc_assert_template_node(ast->next->next, "", + BLOGC_TEMPLATE_NODE_CONTENT); + blogc_assert_template_node(ast->next->next->next, "CHUNDA", + BLOGC_TEMPLATE_NODE_IFDEF); + blogc_assert_template_node(ast->next->next->next->next, "\nbola\n", + BLOGC_TEMPLATE_NODE_CONTENT); + blogc_assert_template_node(ast->next->next->next->next->next, NULL, + BLOGC_TEMPLATE_NODE_ENDIF); + blogc_assert_template_node(ast->next->next->next->next->next->next, "\n", + BLOGC_TEMPLATE_NODE_CONTENT); + bc_slist_t *tmp = ast->next->next->next->next->next->next->next; + blogc_assert_template_node(tmp, "BOLA", BLOGC_TEMPLATE_NODE_IFNDEF); + blogc_assert_template_node(tmp->next, "\nbolao", BLOGC_TEMPLATE_NODE_CONTENT); + blogc_assert_template_node(tmp->next->next, NULL, BLOGC_TEMPLATE_NODE_ENDIF); + blogc_assert_template_node(tmp->next->next->next, "\n", + BLOGC_TEMPLATE_NODE_CONTENT); tmp = tmp->next->next->next->next; - blogc_assert_template_stmt(tmp, NULL, BLOGC_TEMPLATE_ENDBLOCK_STMT); - blogc_assert_template_stmt(tmp->next, "\n", BLOGC_TEMPLATE_CONTENT_STMT); - blogc_assert_template_stmt(tmp->next->next, "listing", - BLOGC_TEMPLATE_BLOCK_STMT); - blogc_assert_template_stmt(tmp->next->next->next, "BOLA", - BLOGC_TEMPLATE_VARIABLE_STMT); - blogc_assert_template_stmt(tmp->next->next->next->next, - NULL, BLOGC_TEMPLATE_ENDBLOCK_STMT); - blogc_assert_template_stmt(tmp->next->next->next->next->next, "\n", - BLOGC_TEMPLATE_CONTENT_STMT); - blogc_assert_template_stmt(tmp->next->next->next->next->next->next, - "listing_once", BLOGC_TEMPLATE_BLOCK_STMT); - blogc_assert_template_stmt(tmp->next->next->next->next->next->next->next, - "asd", BLOGC_TEMPLATE_CONTENT_STMT); - blogc_assert_template_stmt(tmp->next->next->next->next->next->next->next->next, - NULL, BLOGC_TEMPLATE_ENDBLOCK_STMT); - blogc_assert_template_stmt(tmp->next->next->next->next->next->next->next->next->next, - "", BLOGC_TEMPLATE_CONTENT_STMT); + blogc_assert_template_node(tmp, NULL, BLOGC_TEMPLATE_NODE_ENDBLOCK); + blogc_assert_template_node(tmp->next, "\n", BLOGC_TEMPLATE_NODE_CONTENT); + blogc_assert_template_node(tmp->next->next, "listing", + BLOGC_TEMPLATE_NODE_BLOCK); + blogc_assert_template_node(tmp->next->next->next, "BOLA", + BLOGC_TEMPLATE_NODE_VARIABLE); + blogc_assert_template_node(tmp->next->next->next->next, + NULL, BLOGC_TEMPLATE_NODE_ENDBLOCK); + blogc_assert_template_node(tmp->next->next->next->next->next, "\n", + BLOGC_TEMPLATE_NODE_CONTENT); + blogc_assert_template_node(tmp->next->next->next->next->next->next, + "listing_once", BLOGC_TEMPLATE_NODE_BLOCK); + blogc_assert_template_node(tmp->next->next->next->next->next->next->next, + "asd", BLOGC_TEMPLATE_NODE_CONTENT); + blogc_assert_template_node(tmp->next->next->next->next->next->next->next->next, + NULL, BLOGC_TEMPLATE_NODE_ENDBLOCK); + blogc_assert_template_node(tmp->next->next->next->next->next->next->next->next->next, + "", BLOGC_TEMPLATE_NODE_CONTENT); tmp = tmp->next->next->next->next->next->next->next->next->next->next; - blogc_assert_template_stmt(tmp, "BOLA", BLOGC_TEMPLATE_FOREACH_STMT); - blogc_assert_template_stmt(tmp->next, "hahaha", - BLOGC_TEMPLATE_CONTENT_STMT); - blogc_assert_template_stmt(tmp->next->next, NULL, - BLOGC_TEMPLATE_ENDFOREACH_STMT); - blogc_assert_template_stmt(tmp->next->next->next, "\n", - BLOGC_TEMPLATE_CONTENT_STMT); - blogc_assert_template_if_stmt(tmp->next->next->next->next, "BOLA", + blogc_assert_template_node(tmp, "BOLA", BLOGC_TEMPLATE_NODE_FOREACH); + blogc_assert_template_node(tmp->next, "hahaha", + BLOGC_TEMPLATE_NODE_CONTENT); + blogc_assert_template_node(tmp->next->next, NULL, + BLOGC_TEMPLATE_NODE_ENDFOREACH); + blogc_assert_template_node(tmp->next->next->next, "\n", + BLOGC_TEMPLATE_NODE_CONTENT); + blogc_assert_template_if_node(tmp->next->next->next->next, "BOLA", BLOGC_TEMPLATE_OP_EQ, "\"1\\\"0\""); - blogc_assert_template_stmt(tmp->next->next->next->next->next, "aee", - BLOGC_TEMPLATE_CONTENT_STMT); - blogc_assert_template_stmt(tmp->next->next->next->next->next->next, NULL, - BLOGC_TEMPLATE_ELSE_STMT); - blogc_assert_template_stmt(tmp->next->next->next->next->next->next->next, - "fffuuuuuuu", BLOGC_TEMPLATE_CONTENT_STMT); - blogc_assert_template_stmt(tmp->next->next->next->next->next->next->next->next, - NULL, BLOGC_TEMPLATE_ENDIF_STMT); + blogc_assert_template_node(tmp->next->next->next->next->next, "aee", + BLOGC_TEMPLATE_NODE_CONTENT); + blogc_assert_template_node(tmp->next->next->next->next->next->next, NULL, + BLOGC_TEMPLATE_NODE_ELSE); + blogc_assert_template_node(tmp->next->next->next->next->next->next->next, + "fffuuuuuuu", BLOGC_TEMPLATE_NODE_CONTENT); + blogc_assert_template_node(tmp->next->next->next->next->next->next->next->next, + NULL, BLOGC_TEMPLATE_NODE_ENDIF); assert_null(tmp->next->next->next->next->next->next->next->next->next); - blogc_template_free_stmts(stmts); + blogc_template_free_ast(ast); } @@ -144,68 +144,68 @@ test_template_parse_crlf(void **state) "{%- foreach BOLA %}hahaha{% endforeach %}\r\n" "{% if BOLA == \"1\\\"0\" %}aee{% else %}fffuuuuuuu{% endif %}"; bc_error_t *err = NULL; - bc_slist_t *stmts = blogc_template_parse(a, strlen(a), &err); + bc_slist_t *ast = blogc_template_parse(a, strlen(a), &err); assert_null(err); - assert_non_null(stmts); - blogc_assert_template_stmt(stmts, "Test", - BLOGC_TEMPLATE_CONTENT_STMT); - blogc_assert_template_stmt(stmts->next, "entry", - BLOGC_TEMPLATE_BLOCK_STMT); - blogc_assert_template_stmt(stmts->next->next, "", - BLOGC_TEMPLATE_CONTENT_STMT); - blogc_assert_template_stmt(stmts->next->next->next, "CHUNDA", - BLOGC_TEMPLATE_IFDEF_STMT); - blogc_assert_template_stmt(stmts->next->next->next->next, "\r\nbola\r\n", - BLOGC_TEMPLATE_CONTENT_STMT); - blogc_assert_template_stmt(stmts->next->next->next->next->next, NULL, - BLOGC_TEMPLATE_ENDIF_STMT); - blogc_assert_template_stmt(stmts->next->next->next->next->next->next, "\r\n", - BLOGC_TEMPLATE_CONTENT_STMT); - bc_slist_t *tmp = stmts->next->next->next->next->next->next->next; - blogc_assert_template_stmt(tmp, "BOLA", BLOGC_TEMPLATE_IFNDEF_STMT); - blogc_assert_template_stmt(tmp->next, "\r\nbolao", BLOGC_TEMPLATE_CONTENT_STMT); - blogc_assert_template_stmt(tmp->next->next, NULL, BLOGC_TEMPLATE_ENDIF_STMT); - blogc_assert_template_stmt(tmp->next->next->next, "\r\n", - BLOGC_TEMPLATE_CONTENT_STMT); + assert_non_null(ast); + blogc_assert_template_node(ast, "Test", + BLOGC_TEMPLATE_NODE_CONTENT); + blogc_assert_template_node(ast->next, "entry", + BLOGC_TEMPLATE_NODE_BLOCK); + blogc_assert_template_node(ast->next->next, "", + BLOGC_TEMPLATE_NODE_CONTENT); + blogc_assert_template_node(ast->next->next->next, "CHUNDA", + BLOGC_TEMPLATE_NODE_IFDEF); + blogc_assert_template_node(ast->next->next->next->next, "\r\nbola\r\n", + BLOGC_TEMPLATE_NODE_CONTENT); + blogc_assert_template_node(ast->next->next->next->next->next, NULL, + BLOGC_TEMPLATE_NODE_ENDIF); + blogc_assert_template_node(ast->next->next->next->next->next->next, "\r\n", + BLOGC_TEMPLATE_NODE_CONTENT); + bc_slist_t *tmp = ast->next->next->next->next->next->next->next; + blogc_assert_template_node(tmp, "BOLA", BLOGC_TEMPLATE_NODE_IFNDEF); + blogc_assert_template_node(tmp->next, "\r\nbolao", BLOGC_TEMPLATE_NODE_CONTENT); + blogc_assert_template_node(tmp->next->next, NULL, BLOGC_TEMPLATE_NODE_ENDIF); + blogc_assert_template_node(tmp->next->next->next, "\r\n", + BLOGC_TEMPLATE_NODE_CONTENT); tmp = tmp->next->next->next->next; - blogc_assert_template_stmt(tmp, NULL, BLOGC_TEMPLATE_ENDBLOCK_STMT); - blogc_assert_template_stmt(tmp->next, "\r\n", BLOGC_TEMPLATE_CONTENT_STMT); - blogc_assert_template_stmt(tmp->next->next, "listing", - BLOGC_TEMPLATE_BLOCK_STMT); - blogc_assert_template_stmt(tmp->next->next->next, "BOLA", - BLOGC_TEMPLATE_VARIABLE_STMT); - blogc_assert_template_stmt(tmp->next->next->next->next, - NULL, BLOGC_TEMPLATE_ENDBLOCK_STMT); - blogc_assert_template_stmt(tmp->next->next->next->next->next, "\r\n", - BLOGC_TEMPLATE_CONTENT_STMT); - blogc_assert_template_stmt(tmp->next->next->next->next->next->next, - "listing_once", BLOGC_TEMPLATE_BLOCK_STMT); - blogc_assert_template_stmt(tmp->next->next->next->next->next->next->next, - "asd", BLOGC_TEMPLATE_CONTENT_STMT); - blogc_assert_template_stmt(tmp->next->next->next->next->next->next->next->next, - NULL, BLOGC_TEMPLATE_ENDBLOCK_STMT); - blogc_assert_template_stmt(tmp->next->next->next->next->next->next->next->next->next, - "", BLOGC_TEMPLATE_CONTENT_STMT); + blogc_assert_template_node(tmp, NULL, BLOGC_TEMPLATE_NODE_ENDBLOCK); + blogc_assert_template_node(tmp->next, "\r\n", BLOGC_TEMPLATE_NODE_CONTENT); + blogc_assert_template_node(tmp->next->next, "listing", + BLOGC_TEMPLATE_NODE_BLOCK); + blogc_assert_template_node(tmp->next->next->next, "BOLA", + BLOGC_TEMPLATE_NODE_VARIABLE); + blogc_assert_template_node(tmp->next->next->next->next, + NULL, BLOGC_TEMPLATE_NODE_ENDBLOCK); + blogc_assert_template_node(tmp->next->next->next->next->next, "\r\n", + BLOGC_TEMPLATE_NODE_CONTENT); + blogc_assert_template_node(tmp->next->next->next->next->next->next, + "listing_once", BLOGC_TEMPLATE_NODE_BLOCK); + blogc_assert_template_node(tmp->next->next->next->next->next->next->next, + "asd", BLOGC_TEMPLATE_NODE_CONTENT); + blogc_assert_template_node(tmp->next->next->next->next->next->next->next->next, + NULL, BLOGC_TEMPLATE_NODE_ENDBLOCK); + blogc_assert_template_node(tmp->next->next->next->next->next->next->next->next->next, + "", BLOGC_TEMPLATE_NODE_CONTENT); tmp = tmp->next->next->next->next->next->next->next->next->next->next; - blogc_assert_template_stmt(tmp, "BOLA", BLOGC_TEMPLATE_FOREACH_STMT); - blogc_assert_template_stmt(tmp->next, "hahaha", - BLOGC_TEMPLATE_CONTENT_STMT); - blogc_assert_template_stmt(tmp->next->next, NULL, - BLOGC_TEMPLATE_ENDFOREACH_STMT); - blogc_assert_template_stmt(tmp->next->next->next, "\r\n", - BLOGC_TEMPLATE_CONTENT_STMT); - blogc_assert_template_if_stmt(tmp->next->next->next->next, "BOLA", + blogc_assert_template_node(tmp, "BOLA", BLOGC_TEMPLATE_NODE_FOREACH); + blogc_assert_template_node(tmp->next, "hahaha", + BLOGC_TEMPLATE_NODE_CONTENT); + blogc_assert_template_node(tmp->next->next, NULL, + BLOGC_TEMPLATE_NODE_ENDFOREACH); + blogc_assert_template_node(tmp->next->next->next, "\r\n", + BLOGC_TEMPLATE_NODE_CONTENT); + blogc_assert_template_if_node(tmp->next->next->next->next, "BOLA", BLOGC_TEMPLATE_OP_EQ, "\"1\\\"0\""); - blogc_assert_template_stmt(tmp->next->next->next->next->next, "aee", - BLOGC_TEMPLATE_CONTENT_STMT); - blogc_assert_template_stmt(tmp->next->next->next->next->next->next, NULL, - BLOGC_TEMPLATE_ELSE_STMT); - blogc_assert_template_stmt(tmp->next->next->next->next->next->next->next, - "fffuuuuuuu", BLOGC_TEMPLATE_CONTENT_STMT); - blogc_assert_template_stmt(tmp->next->next->next->next->next->next->next->next, - NULL, BLOGC_TEMPLATE_ENDIF_STMT); + blogc_assert_template_node(tmp->next->next->next->next->next, "aee", + BLOGC_TEMPLATE_NODE_CONTENT); + blogc_assert_template_node(tmp->next->next->next->next->next->next, NULL, + BLOGC_TEMPLATE_NODE_ELSE); + blogc_assert_template_node(tmp->next->next->next->next->next->next->next, + "fffuuuuuuu", BLOGC_TEMPLATE_NODE_CONTENT); + blogc_assert_template_node(tmp->next->next->next->next->next->next->next->next, + NULL, BLOGC_TEMPLATE_NODE_ENDIF); assert_null(tmp->next->next->next->next->next->next->next->next->next); - blogc_template_free_stmts(stmts); + blogc_template_free_ast(ast); } @@ -236,105 +236,105 @@ test_template_parse_html(void **state) " \n" "\n"; bc_error_t *err = NULL; - bc_slist_t *stmts = blogc_template_parse(a, strlen(a), &err); + bc_slist_t *ast = blogc_template_parse(a, strlen(a), &err); assert_null(err); - assert_non_null(stmts); - blogc_assert_template_stmt(stmts, "\n \n ", - BLOGC_TEMPLATE_CONTENT_STMT); - blogc_assert_template_stmt(stmts->next, "entry", - BLOGC_TEMPLATE_BLOCK_STMT); - blogc_assert_template_stmt(stmts->next->next, - "\n My cool blog >> ", BLOGC_TEMPLATE_CONTENT_STMT); - blogc_assert_template_stmt(stmts->next->next->next, "TITLE", - BLOGC_TEMPLATE_VARIABLE_STMT); - blogc_assert_template_stmt(stmts->next->next->next->next, - "\n ", BLOGC_TEMPLATE_CONTENT_STMT); - blogc_assert_template_stmt(stmts->next->next->next->next->next, NULL, - BLOGC_TEMPLATE_ENDBLOCK_STMT); - blogc_assert_template_stmt(stmts->next->next->next->next->next->next, - "\n ", BLOGC_TEMPLATE_CONTENT_STMT); - blogc_assert_template_stmt(stmts->next->next->next->next->next->next->next, - "listing_once", BLOGC_TEMPLATE_BLOCK_STMT); - bc_slist_t *tmp = stmts->next->next->next->next->next->next->next->next; - blogc_assert_template_stmt(tmp, + assert_non_null(ast); + blogc_assert_template_node(ast, "\n \n ", + BLOGC_TEMPLATE_NODE_CONTENT); + blogc_assert_template_node(ast->next, "entry", + BLOGC_TEMPLATE_NODE_BLOCK); + blogc_assert_template_node(ast->next->next, + "\n My cool blog >> ", BLOGC_TEMPLATE_NODE_CONTENT); + blogc_assert_template_node(ast->next->next->next, "TITLE", + BLOGC_TEMPLATE_NODE_VARIABLE); + blogc_assert_template_node(ast->next->next->next->next, + "\n ", BLOGC_TEMPLATE_NODE_CONTENT); + blogc_assert_template_node(ast->next->next->next->next->next, NULL, + BLOGC_TEMPLATE_NODE_ENDBLOCK); + blogc_assert_template_node(ast->next->next->next->next->next->next, + "\n ", BLOGC_TEMPLATE_NODE_CONTENT); + blogc_assert_template_node(ast->next->next->next->next->next->next->next, + "listing_once", BLOGC_TEMPLATE_NODE_BLOCK); + bc_slist_t *tmp = ast->next->next->next->next->next->next->next->next; + blogc_assert_template_node(tmp, "\n My cool blog - Main page\n ", - BLOGC_TEMPLATE_CONTENT_STMT); - blogc_assert_template_stmt(tmp->next, NULL, BLOGC_TEMPLATE_ENDBLOCK_STMT); - blogc_assert_template_stmt(tmp->next->next, + BLOGC_TEMPLATE_NODE_CONTENT); + blogc_assert_template_node(tmp->next, NULL, BLOGC_TEMPLATE_NODE_ENDBLOCK); + blogc_assert_template_node(tmp->next->next, "\n \n \n

My cool blog

\n ", - BLOGC_TEMPLATE_CONTENT_STMT); - blogc_assert_template_stmt(tmp->next->next->next, "entry", - BLOGC_TEMPLATE_BLOCK_STMT); - blogc_assert_template_stmt(tmp->next->next->next->next, - "\n

", BLOGC_TEMPLATE_CONTENT_STMT); - blogc_assert_template_stmt(tmp->next->next->next->next->next, - "TITLE", BLOGC_TEMPLATE_VARIABLE_STMT); - blogc_assert_template_stmt(tmp->next->next->next->next->next->next, - "

\n ", BLOGC_TEMPLATE_CONTENT_STMT); - blogc_assert_template_stmt(tmp->next->next->next->next->next->next->next, - "DATE", BLOGC_TEMPLATE_IFDEF_STMT); + BLOGC_TEMPLATE_NODE_CONTENT); + blogc_assert_template_node(tmp->next->next->next, "entry", + BLOGC_TEMPLATE_NODE_BLOCK); + blogc_assert_template_node(tmp->next->next->next->next, + "\n

", BLOGC_TEMPLATE_NODE_CONTENT); + blogc_assert_template_node(tmp->next->next->next->next->next, + "TITLE", BLOGC_TEMPLATE_NODE_VARIABLE); + blogc_assert_template_node(tmp->next->next->next->next->next->next, + "

\n ", BLOGC_TEMPLATE_NODE_CONTENT); + blogc_assert_template_node(tmp->next->next->next->next->next->next->next, + "DATE", BLOGC_TEMPLATE_NODE_IFDEF); tmp = tmp->next->next->next->next->next->next->next->next; - blogc_assert_template_stmt(tmp, "

Published in: ", - BLOGC_TEMPLATE_CONTENT_STMT); - blogc_assert_template_stmt(tmp->next, "DATE", BLOGC_TEMPLATE_VARIABLE_STMT); - blogc_assert_template_stmt(tmp->next->next, "

", - BLOGC_TEMPLATE_CONTENT_STMT); - blogc_assert_template_stmt(tmp->next->next->next, NULL, - BLOGC_TEMPLATE_ENDIF_STMT); - blogc_assert_template_stmt(tmp->next->next->next->next, "\n
",
-        BLOGC_TEMPLATE_CONTENT_STMT);
-    blogc_assert_template_stmt(tmp->next->next->next->next->next,
-        "CONTENT", BLOGC_TEMPLATE_VARIABLE_STMT);
-    blogc_assert_template_stmt(tmp->next->next->next->next->next->next,
-        "
\n ", BLOGC_TEMPLATE_CONTENT_STMT); - blogc_assert_template_stmt(tmp->next->next->next->next->next->next->next, - NULL, BLOGC_TEMPLATE_ENDBLOCK_STMT); + blogc_assert_template_node(tmp, "

Published in: ", + BLOGC_TEMPLATE_NODE_CONTENT); + blogc_assert_template_node(tmp->next, "DATE", BLOGC_TEMPLATE_NODE_VARIABLE); + blogc_assert_template_node(tmp->next->next, "

", + BLOGC_TEMPLATE_NODE_CONTENT); + blogc_assert_template_node(tmp->next->next->next, NULL, + BLOGC_TEMPLATE_NODE_ENDIF); + blogc_assert_template_node(tmp->next->next->next->next, "\n
",
+        BLOGC_TEMPLATE_NODE_CONTENT);
+    blogc_assert_template_node(tmp->next->next->next->next->next,
+        "CONTENT", BLOGC_TEMPLATE_NODE_VARIABLE);
+    blogc_assert_template_node(tmp->next->next->next->next->next->next,
+        "
\n ", BLOGC_TEMPLATE_NODE_CONTENT); + blogc_assert_template_node(tmp->next->next->next->next->next->next->next, + NULL, BLOGC_TEMPLATE_NODE_ENDBLOCK); tmp = tmp->next->next->next->next->next->next->next->next; - blogc_assert_template_stmt(tmp, "\n ", BLOGC_TEMPLATE_CONTENT_STMT); - blogc_assert_template_stmt(tmp->next, "listing_once", - BLOGC_TEMPLATE_BLOCK_STMT); - blogc_assert_template_stmt(tmp->next->next, "", + BLOGC_TEMPLATE_NODE_CONTENT); + blogc_assert_template_node(tmp->next->next->next->next, NULL, + BLOGC_TEMPLATE_NODE_ENDBLOCK); + blogc_assert_template_node(tmp->next->next->next->next->next, + "\n \n\n", BLOGC_TEMPLATE_NODE_CONTENT); assert_null(tmp->next->next->next->next->next->next); - blogc_template_free_stmts(stmts); + blogc_template_free_ast(ast); } @@ -346,29 +346,29 @@ test_template_parse_ifdef_and_var_outside_block(void **state) "{{ BOLA }}\n" "{% ifndef CHUNDA %}{{ CHUNDA }}{% endif %}\n"; bc_error_t *err = NULL; - bc_slist_t *stmts = blogc_template_parse(a, strlen(a), &err); + bc_slist_t *ast = blogc_template_parse(a, strlen(a), &err); assert_null(err); - assert_non_null(stmts); - blogc_assert_template_stmt(stmts, "GUDA", BLOGC_TEMPLATE_IFDEF_STMT); - blogc_assert_template_stmt(stmts->next, "bola", - BLOGC_TEMPLATE_CONTENT_STMT); - blogc_assert_template_stmt(stmts->next->next, NULL, - BLOGC_TEMPLATE_ENDIF_STMT); - blogc_assert_template_stmt(stmts->next->next->next, "\n", - BLOGC_TEMPLATE_CONTENT_STMT); - blogc_assert_template_stmt(stmts->next->next->next->next, "BOLA", - BLOGC_TEMPLATE_VARIABLE_STMT); - blogc_assert_template_stmt(stmts->next->next->next->next->next, "\n", - BLOGC_TEMPLATE_CONTENT_STMT); - blogc_assert_template_stmt(stmts->next->next->next->next->next->next, - "CHUNDA", BLOGC_TEMPLATE_IFNDEF_STMT); - bc_slist_t *tmp = stmts->next->next->next->next->next->next->next; - blogc_assert_template_stmt(tmp, "CHUNDA", BLOGC_TEMPLATE_VARIABLE_STMT); - blogc_assert_template_stmt(tmp->next, NULL, BLOGC_TEMPLATE_ENDIF_STMT); - blogc_assert_template_stmt(tmp->next->next, "\n", - BLOGC_TEMPLATE_CONTENT_STMT); + assert_non_null(ast); + blogc_assert_template_node(ast, "GUDA", BLOGC_TEMPLATE_NODE_IFDEF); + blogc_assert_template_node(ast->next, "bola", + BLOGC_TEMPLATE_NODE_CONTENT); + blogc_assert_template_node(ast->next->next, NULL, + BLOGC_TEMPLATE_NODE_ENDIF); + blogc_assert_template_node(ast->next->next->next, "\n", + BLOGC_TEMPLATE_NODE_CONTENT); + blogc_assert_template_node(ast->next->next->next->next, "BOLA", + BLOGC_TEMPLATE_NODE_VARIABLE); + blogc_assert_template_node(ast->next->next->next->next->next, "\n", + BLOGC_TEMPLATE_NODE_CONTENT); + blogc_assert_template_node(ast->next->next->next->next->next->next, + "CHUNDA", BLOGC_TEMPLATE_NODE_IFNDEF); + bc_slist_t *tmp = ast->next->next->next->next->next->next->next; + blogc_assert_template_node(tmp, "CHUNDA", BLOGC_TEMPLATE_NODE_VARIABLE); + blogc_assert_template_node(tmp->next, NULL, BLOGC_TEMPLATE_NODE_ENDIF); + blogc_assert_template_node(tmp->next->next, "\n", + BLOGC_TEMPLATE_NODE_CONTENT); assert_null(tmp->next->next->next); - blogc_template_free_stmts(stmts); + blogc_template_free_ast(ast); } @@ -393,50 +393,50 @@ test_template_parse_nested_else(void **state) "{% endif %}\n" "{% endif %}\n"; bc_error_t *err = NULL; - bc_slist_t *stmts = blogc_template_parse(a, strlen(a), &err); + bc_slist_t *ast = blogc_template_parse(a, strlen(a), &err); assert_null(err); - assert_non_null(stmts); - blogc_assert_template_stmt(stmts, "GUDA", BLOGC_TEMPLATE_IFDEF_STMT); - blogc_assert_template_stmt(stmts->next, "\n", BLOGC_TEMPLATE_CONTENT_STMT); - blogc_assert_template_stmt(stmts->next->next, "BOLA", BLOGC_TEMPLATE_IFDEF_STMT); - blogc_assert_template_stmt(stmts->next->next->next, "\nasd\n", - BLOGC_TEMPLATE_CONTENT_STMT); - blogc_assert_template_stmt(stmts->next->next->next->next, NULL, - BLOGC_TEMPLATE_ELSE_STMT); - blogc_assert_template_stmt(stmts->next->next->next->next->next, "\n", - BLOGC_TEMPLATE_CONTENT_STMT); - blogc_assert_template_stmt(stmts->next->next->next->next->next->next, - "CHUNDA", BLOGC_TEMPLATE_IFDEF_STMT); - blogc_assert_template_stmt(stmts->next->next->next->next->next->next->next, - "\nqwe\n", BLOGC_TEMPLATE_CONTENT_STMT); - bc_slist_t *tmp = stmts->next->next->next->next->next->next->next->next; - blogc_assert_template_stmt(tmp, NULL, BLOGC_TEMPLATE_ELSE_STMT); - blogc_assert_template_stmt(tmp->next, "\nrty\n", BLOGC_TEMPLATE_CONTENT_STMT); - blogc_assert_template_stmt(tmp->next->next, NULL, - BLOGC_TEMPLATE_ENDIF_STMT); - blogc_assert_template_stmt(tmp->next->next->next, "\n", - BLOGC_TEMPLATE_CONTENT_STMT); - blogc_assert_template_stmt(tmp->next->next->next->next, NULL, - BLOGC_TEMPLATE_ENDIF_STMT); - blogc_assert_template_stmt(tmp->next->next->next->next->next, "\n", - BLOGC_TEMPLATE_CONTENT_STMT); - blogc_assert_template_stmt(tmp->next->next->next->next->next->next, - "LOL", BLOGC_TEMPLATE_IFDEF_STMT); - blogc_assert_template_stmt(tmp->next->next->next->next->next->next->next, - "\nzxc\n", BLOGC_TEMPLATE_CONTENT_STMT); + assert_non_null(ast); + blogc_assert_template_node(ast, "GUDA", BLOGC_TEMPLATE_NODE_IFDEF); + blogc_assert_template_node(ast->next, "\n", BLOGC_TEMPLATE_NODE_CONTENT); + blogc_assert_template_node(ast->next->next, "BOLA", BLOGC_TEMPLATE_NODE_IFDEF); + blogc_assert_template_node(ast->next->next->next, "\nasd\n", + BLOGC_TEMPLATE_NODE_CONTENT); + blogc_assert_template_node(ast->next->next->next->next, NULL, + BLOGC_TEMPLATE_NODE_ELSE); + blogc_assert_template_node(ast->next->next->next->next->next, "\n", + BLOGC_TEMPLATE_NODE_CONTENT); + blogc_assert_template_node(ast->next->next->next->next->next->next, + "CHUNDA", BLOGC_TEMPLATE_NODE_IFDEF); + blogc_assert_template_node(ast->next->next->next->next->next->next->next, + "\nqwe\n", BLOGC_TEMPLATE_NODE_CONTENT); + bc_slist_t *tmp = ast->next->next->next->next->next->next->next->next; + blogc_assert_template_node(tmp, NULL, BLOGC_TEMPLATE_NODE_ELSE); + blogc_assert_template_node(tmp->next, "\nrty\n", BLOGC_TEMPLATE_NODE_CONTENT); + blogc_assert_template_node(tmp->next->next, NULL, + BLOGC_TEMPLATE_NODE_ENDIF); + blogc_assert_template_node(tmp->next->next->next, "\n", + BLOGC_TEMPLATE_NODE_CONTENT); + blogc_assert_template_node(tmp->next->next->next->next, NULL, + BLOGC_TEMPLATE_NODE_ENDIF); + blogc_assert_template_node(tmp->next->next->next->next->next, "\n", + BLOGC_TEMPLATE_NODE_CONTENT); + blogc_assert_template_node(tmp->next->next->next->next->next->next, + "LOL", BLOGC_TEMPLATE_NODE_IFDEF); + blogc_assert_template_node(tmp->next->next->next->next->next->next->next, + "\nzxc\n", BLOGC_TEMPLATE_NODE_CONTENT); tmp = tmp->next->next->next->next->next->next->next->next; - blogc_assert_template_stmt(tmp, NULL, BLOGC_TEMPLATE_ELSE_STMT); - blogc_assert_template_stmt(tmp->next, "\nbnm\n", BLOGC_TEMPLATE_CONTENT_STMT); - blogc_assert_template_stmt(tmp->next->next, NULL, - BLOGC_TEMPLATE_ENDIF_STMT); - blogc_assert_template_stmt(tmp->next->next->next, "\n", - BLOGC_TEMPLATE_CONTENT_STMT); - blogc_assert_template_stmt(tmp->next->next->next->next, NULL, - BLOGC_TEMPLATE_ENDIF_STMT); - blogc_assert_template_stmt(tmp->next->next->next->next->next, "\n", - BLOGC_TEMPLATE_CONTENT_STMT); + blogc_assert_template_node(tmp, NULL, BLOGC_TEMPLATE_NODE_ELSE); + blogc_assert_template_node(tmp->next, "\nbnm\n", BLOGC_TEMPLATE_NODE_CONTENT); + blogc_assert_template_node(tmp->next->next, NULL, + BLOGC_TEMPLATE_NODE_ENDIF); + blogc_assert_template_node(tmp->next->next->next, "\n", + BLOGC_TEMPLATE_NODE_CONTENT); + blogc_assert_template_node(tmp->next->next->next->next, NULL, + BLOGC_TEMPLATE_NODE_ENDIF); + blogc_assert_template_node(tmp->next->next->next->next->next, "\n", + BLOGC_TEMPLATE_NODE_CONTENT); assert_null(tmp->next->next->next->next->next->next); - blogc_template_free_stmts(stmts); + blogc_template_free_ast(ast); } @@ -445,9 +445,9 @@ test_template_parse_invalid_block_start(void **state) { const char *a = "{% ASD %}\n"; bc_error_t *err = NULL; - bc_slist_t *stmts = blogc_template_parse(a, strlen(a), &err); + bc_slist_t *ast = blogc_template_parse(a, strlen(a), &err); assert_non_null(err); - assert_null(stmts); + assert_null(ast); assert_int_equal(err->type, BLOGC_ERROR_TEMPLATE_PARSER); assert_string_equal(err->msg, "Invalid statement syntax. Must begin with lowercase letter.\n" @@ -455,9 +455,9 @@ test_template_parse_invalid_block_start(void **state) bc_error_free(err); a = "{%-- block entry %}\n"; err = NULL; - stmts = blogc_template_parse(a, strlen(a), &err); + ast = blogc_template_parse(a, strlen(a), &err); assert_non_null(err); - assert_null(stmts); + assert_null(ast); assert_int_equal(err->type, BLOGC_ERROR_TEMPLATE_PARSER); assert_string_equal(err->msg, "Invalid statement syntax. Duplicated whitespace cleaner before statement.\n" @@ -465,9 +465,9 @@ test_template_parse_invalid_block_start(void **state) bc_error_free(err); a = "{% block entry --%}\n"; err = NULL; - stmts = blogc_template_parse(a, strlen(a), &err); + ast = blogc_template_parse(a, strlen(a), &err); assert_non_null(err); - assert_null(stmts); + assert_null(ast); assert_int_equal(err->type, BLOGC_ERROR_TEMPLATE_PARSER); assert_string_equal(err->msg, "Invalid statement syntax. Duplicated whitespace cleaner after statement.\n" @@ -483,9 +483,9 @@ test_template_parse_invalid_block_nested(void **state) "{% block entry %}\n" "{% block listing %}\n"; bc_error_t *err = NULL; - bc_slist_t *stmts = blogc_template_parse(a, strlen(a), &err); + bc_slist_t *ast = blogc_template_parse(a, strlen(a), &err); assert_non_null(err); - assert_null(stmts); + assert_null(ast); assert_int_equal(err->type, BLOGC_ERROR_TEMPLATE_PARSER); assert_string_equal(err->msg, "Blocks can't be nested.\n" @@ -501,9 +501,9 @@ test_template_parse_invalid_foreach_nested(void **state) "{% foreach A %}\n" "{% foreach B %}\n"; bc_error_t *err = NULL; - bc_slist_t *stmts = blogc_template_parse(a, strlen(a), &err); + bc_slist_t *ast = blogc_template_parse(a, strlen(a), &err); assert_non_null(err); - assert_null(stmts); + assert_null(ast); assert_int_equal(err->type, BLOGC_ERROR_TEMPLATE_PARSER); assert_string_equal(err->msg, "'foreach' statements can't be nested.\n" @@ -517,9 +517,9 @@ test_template_parse_invalid_block_not_open(void **state) { const char *a = "{% endblock %}\n"; bc_error_t *err = NULL; - bc_slist_t *stmts = blogc_template_parse(a, strlen(a), &err); + bc_slist_t *ast = blogc_template_parse(a, strlen(a), &err); assert_non_null(err); - assert_null(stmts); + assert_null(ast); assert_int_equal(err->type, BLOGC_ERROR_TEMPLATE_PARSER); assert_string_equal(err->msg, "'endblock' statement without an open 'block' statement.\n" @@ -533,9 +533,9 @@ test_template_parse_invalid_endif_not_open(void **state) { const char *a = "{% block listing %}{% endif %}{% endblock %}\n"; bc_error_t *err = NULL; - bc_slist_t *stmts = blogc_template_parse(a, strlen(a), &err); + bc_slist_t *ast = blogc_template_parse(a, strlen(a), &err); assert_non_null(err); - assert_null(stmts); + assert_null(ast); assert_int_equal(err->type, BLOGC_ERROR_TEMPLATE_PARSER); assert_string_equal(err->msg, "'endif' statement without an open 'if', 'ifdef' or 'ifndef' statement.\n" @@ -550,9 +550,9 @@ test_template_parse_invalid_endif_not_open_inside_block(void **state) { const char *a = "{% ifdef BOLA %}{% block listing %}{% endif %}{% endblock %}"; bc_error_t *err = NULL; - bc_slist_t *stmts = blogc_template_parse(a, strlen(a), &err); + bc_slist_t *ast = blogc_template_parse(a, strlen(a), &err); assert_non_null(err); - assert_null(stmts); + assert_null(ast); assert_int_equal(err->type, BLOGC_ERROR_TEMPLATE_PARSER); assert_string_equal(err->msg, "'endif' statement without an open 'if', 'ifdef' or 'ifndef' statement.\n" @@ -567,9 +567,9 @@ test_template_parse_invalid_else_not_open_inside_block(void **state) { const char *a = "{% ifdef BOLA %}{% block listing %}{% else %}{% endif %}{% endblock %}"; bc_error_t *err = NULL; - bc_slist_t *stmts = blogc_template_parse(a, strlen(a), &err); + bc_slist_t *ast = blogc_template_parse(a, strlen(a), &err); assert_non_null(err); - assert_null(stmts); + assert_null(ast); assert_int_equal(err->type, BLOGC_ERROR_TEMPLATE_PARSER); assert_string_equal(err->msg, "'else' statement without an open 'if', 'ifdef' or 'ifndef' statement.\n" @@ -584,9 +584,9 @@ test_template_parse_invalid_endforeach_not_open(void **state) { const char *a = "{% endforeach %}\n"; bc_error_t *err = NULL; - bc_slist_t *stmts = blogc_template_parse(a, strlen(a), &err); + bc_slist_t *ast = blogc_template_parse(a, strlen(a), &err); assert_non_null(err); - assert_null(stmts); + assert_null(ast); assert_int_equal(err->type, BLOGC_ERROR_TEMPLATE_PARSER); assert_string_equal(err->msg, "'endforeach' statement without an open 'foreach' statement.\n" @@ -601,9 +601,9 @@ test_template_parse_invalid_endforeach_not_open_inside_block(void **state) const char *a = "{% foreach TAGS %}{% block entry %}{% endforeach %}" "{% endblock %}\n"; bc_error_t *err = NULL; - bc_slist_t *stmts = blogc_template_parse(a, strlen(a), &err); + bc_slist_t *ast = blogc_template_parse(a, strlen(a), &err); assert_non_null(err); - assert_null(stmts); + assert_null(ast); assert_int_equal(err->type, BLOGC_ERROR_TEMPLATE_PARSER); assert_string_equal(err->msg, "'endforeach' statement without an open 'foreach' statement.\n" @@ -619,9 +619,9 @@ test_template_parse_invalid_endforeach_not_open_inside_block2(void **state) const char *a = "{% block entry %}{% foreach TAGS %}" "{% endforeach %}{% endforeach %}{% endblock %}\n"; bc_error_t *err = NULL; - bc_slist_t *stmts = blogc_template_parse(a, strlen(a), &err); + bc_slist_t *ast = blogc_template_parse(a, strlen(a), &err); assert_non_null(err); - assert_null(stmts); + assert_null(ast); assert_int_equal(err->type, BLOGC_ERROR_TEMPLATE_PARSER); assert_string_equal(err->msg, "'endforeach' statement without an open 'foreach' statement.\n" @@ -637,9 +637,9 @@ test_template_parse_invalid_endforeach_not_closed_inside_block(void **state) const char *a = "{% block entry %}{% foreach TAGS %}{% endblock %}" "{% endforeach %}\n"; bc_error_t *err = NULL; - bc_slist_t *stmts = blogc_template_parse(a, strlen(a), &err); + bc_slist_t *ast = blogc_template_parse(a, strlen(a), &err); assert_non_null(err); - assert_null(stmts); + assert_null(ast); assert_int_equal(err->type, BLOGC_ERROR_TEMPLATE_PARSER); assert_string_equal(err->msg, "An open 'foreach' statement was not closed inside a 'entry' block!"); @@ -653,9 +653,9 @@ test_template_parse_invalid_endforeach_not_closed_inside_block2(void **state) const char *a = "{% block entry %}{% foreach TAGS %}{% endforeach %}" "{% foreach TAGS %}{% endblock %}{% endforeach %}\n"; bc_error_t *err = NULL; - bc_slist_t *stmts = blogc_template_parse(a, strlen(a), &err); + bc_slist_t *ast = blogc_template_parse(a, strlen(a), &err); assert_non_null(err); - assert_null(stmts); + assert_null(ast); assert_int_equal(err->type, BLOGC_ERROR_TEMPLATE_PARSER); assert_string_equal(err->msg, "An open 'foreach' statement was not closed inside a 'entry' block!"); @@ -668,9 +668,9 @@ test_template_parse_invalid_block_name(void **state) { const char *a = "{% chunda %}\n"; bc_error_t *err = NULL; - bc_slist_t *stmts = blogc_template_parse(a, strlen(a), &err); + bc_slist_t *ast = blogc_template_parse(a, strlen(a), &err); assert_non_null(err); - assert_null(stmts); + assert_null(ast); assert_int_equal(err->type, BLOGC_ERROR_TEMPLATE_PARSER); assert_string_equal(err->msg, "Invalid statement type: Allowed types are: 'block', 'endblock', 'if', " @@ -685,9 +685,9 @@ test_template_parse_invalid_block_type_start(void **state) { const char *a = "{% block ENTRY %}\n"; bc_error_t *err = NULL; - bc_slist_t *stmts = blogc_template_parse(a, strlen(a), &err); + bc_slist_t *ast = blogc_template_parse(a, strlen(a), &err); assert_non_null(err); - assert_null(stmts); + assert_null(ast); assert_int_equal(err->type, BLOGC_ERROR_TEMPLATE_PARSER); assert_string_equal(err->msg, "Invalid block syntax. Must begin with lowercase letter.\n" @@ -701,9 +701,9 @@ test_template_parse_invalid_block_type(void **state) { const char *a = "{% block chunda %}\n"; bc_error_t *err = NULL; - bc_slist_t *stmts = blogc_template_parse(a, strlen(a), &err); + bc_slist_t *ast = blogc_template_parse(a, strlen(a), &err); assert_non_null(err); - assert_null(stmts); + assert_null(ast); assert_int_equal(err->type, BLOGC_ERROR_TEMPLATE_PARSER); assert_string_equal(err->msg, "Invalid block type. Allowed types are: 'entry', 'listing' and 'listing_once'.\n" @@ -717,9 +717,9 @@ test_template_parse_invalid_ifdef_start(void **state) { const char *a = "{% block entry %}{% ifdef guda %}\n"; bc_error_t *err = NULL; - bc_slist_t *stmts = blogc_template_parse(a, strlen(a), &err); + bc_slist_t *ast = blogc_template_parse(a, strlen(a), &err); assert_non_null(err); - assert_null(stmts); + assert_null(ast); assert_int_equal(err->type, BLOGC_ERROR_TEMPLATE_PARSER); assert_string_equal(err->msg, "Invalid variable name. Must begin with uppercase letter.\n" @@ -734,9 +734,9 @@ test_template_parse_invalid_foreach_start(void **state) { const char *a = "{% block entry %}{% foreach guda %}\n"; bc_error_t *err = NULL; - bc_slist_t *stmts = blogc_template_parse(a, strlen(a), &err); + bc_slist_t *ast = blogc_template_parse(a, strlen(a), &err); assert_non_null(err); - assert_null(stmts); + assert_null(ast); assert_int_equal(err->type, BLOGC_ERROR_TEMPLATE_PARSER); assert_string_equal(err->msg, "Invalid foreach variable name. Must begin with uppercase letter.\n" @@ -751,9 +751,9 @@ test_template_parse_invalid_ifdef_variable(void **state) { const char *a = "{% block entry %}{% ifdef BoLA %}\n"; bc_error_t *err = NULL; - bc_slist_t *stmts = blogc_template_parse(a, strlen(a), &err); + bc_slist_t *ast = blogc_template_parse(a, strlen(a), &err); assert_non_null(err); - assert_null(stmts); + assert_null(ast); assert_int_equal(err->type, BLOGC_ERROR_TEMPLATE_PARSER); assert_string_equal(err->msg, "Invalid variable name. Must be uppercase letter, number or '_'.\n" @@ -768,9 +768,9 @@ test_template_parse_invalid_ifdef_variable2(void **state) { const char *a = "{% block entry %}{% ifdef 0123 %}\n"; bc_error_t *err = NULL; - bc_slist_t *stmts = blogc_template_parse(a, strlen(a), &err); + bc_slist_t *ast = blogc_template_parse(a, strlen(a), &err); assert_non_null(err); - assert_null(stmts); + assert_null(ast); assert_int_equal(err->type, BLOGC_ERROR_TEMPLATE_PARSER); assert_string_equal(err->msg, "Invalid variable name. Must begin with uppercase letter.\n" @@ -785,9 +785,9 @@ test_template_parse_invalid_foreach_variable(void **state) { const char *a = "{% block entry %}{% foreach BoLA %}\n"; bc_error_t *err = NULL; - bc_slist_t *stmts = blogc_template_parse(a, strlen(a), &err); + bc_slist_t *ast = blogc_template_parse(a, strlen(a), &err); assert_non_null(err); - assert_null(stmts); + assert_null(ast); assert_int_equal(err->type, BLOGC_ERROR_TEMPLATE_PARSER); assert_string_equal(err->msg, "Invalid foreach variable name. Must be uppercase letter, number or '_'.\n" @@ -802,9 +802,9 @@ test_template_parse_invalid_foreach_variable2(void **state) { const char *a = "{% block entry %}{% foreach 0123 %}\n"; bc_error_t *err = NULL; - bc_slist_t *stmts = blogc_template_parse(a, strlen(a), &err); + bc_slist_t *ast = blogc_template_parse(a, strlen(a), &err); assert_non_null(err); - assert_null(stmts); + assert_null(ast); assert_int_equal(err->type, BLOGC_ERROR_TEMPLATE_PARSER); assert_string_equal(err->msg, "Invalid foreach variable name. Must begin with uppercase letter.\n" @@ -819,9 +819,9 @@ test_template_parse_invalid_if_operator(void **state) { const char *a = "{% block entry %}{% if BOLA = \"asd\" %}\n"; bc_error_t *err = NULL; - bc_slist_t *stmts = blogc_template_parse(a, strlen(a), &err); + bc_slist_t *ast = blogc_template_parse(a, strlen(a), &err); assert_non_null(err); - assert_null(stmts); + assert_null(ast); assert_int_equal(err->type, BLOGC_ERROR_TEMPLATE_PARSER); assert_string_equal(err->msg, "Invalid 'if' operator. Must be '<', '>', '<=', '>=', '==' or '!='.\n" @@ -836,9 +836,9 @@ test_template_parse_invalid_if_operand(void **state) { const char *a = "{% block entry %}{% if BOLA == asd %}\n"; bc_error_t *err = NULL; - bc_slist_t *stmts = blogc_template_parse(a, strlen(a), &err); + bc_slist_t *ast = blogc_template_parse(a, strlen(a), &err); assert_non_null(err); - assert_null(stmts); + assert_null(ast); assert_int_equal(err->type, BLOGC_ERROR_TEMPLATE_PARSER); assert_string_equal(err->msg, "Invalid 'if' operand. Must be double-quoted static string or variable.\n" @@ -853,9 +853,9 @@ test_template_parse_invalid_if_operand2(void **state) { const char *a = "{% block entry %}{% if BOLA == \"asd %}\n"; bc_error_t *err = NULL; - bc_slist_t *stmts = blogc_template_parse(a, strlen(a), &err); + bc_slist_t *ast = blogc_template_parse(a, strlen(a), &err); assert_non_null(err); - assert_null(stmts); + assert_null(ast); assert_int_equal(err->type, BLOGC_ERROR_TEMPLATE_PARSER); assert_string_equal(err->msg, "Found an open double-quoted string.\n" @@ -870,9 +870,9 @@ test_template_parse_invalid_if_operand3(void **state) { const char *a = "{% block entry %}{% if BOLA == 0123 %}\n"; bc_error_t *err = NULL; - bc_slist_t *stmts = blogc_template_parse(a, strlen(a), &err); + bc_slist_t *ast = blogc_template_parse(a, strlen(a), &err); assert_non_null(err); - assert_null(stmts); + assert_null(ast); assert_int_equal(err->type, BLOGC_ERROR_TEMPLATE_PARSER); assert_string_equal(err->msg, "Invalid 'if' operand. Must be double-quoted static string or variable.\n" @@ -887,9 +887,9 @@ test_template_parse_invalid_else1(void **state) { const char *a = "{% else %}\n"; bc_error_t *err = NULL; - bc_slist_t *stmts = blogc_template_parse(a, strlen(a), &err); + bc_slist_t *ast = blogc_template_parse(a, strlen(a), &err); assert_non_null(err); - assert_null(stmts); + assert_null(ast); assert_int_equal(err->type, BLOGC_ERROR_TEMPLATE_PARSER); assert_string_equal(err->msg, "'else' statement without an open 'if', 'ifdef' or 'ifndef' statement.\n" @@ -903,9 +903,9 @@ test_template_parse_invalid_else2(void **state) { const char *a = "{% if BOLA == \"123\" %}{% if GUDA == \"1\" %}{% else %}{% else %}\n"; bc_error_t *err = NULL; - bc_slist_t *stmts = blogc_template_parse(a, strlen(a), &err); + bc_slist_t *ast = blogc_template_parse(a, strlen(a), &err); assert_non_null(err); - assert_null(stmts); + assert_null(ast); assert_int_equal(err->type, BLOGC_ERROR_TEMPLATE_PARSER); assert_string_equal(err->msg, "More than one 'else' statement for an open 'if', 'ifdef' or 'ifndef' " @@ -927,9 +927,9 @@ test_template_parse_invalid_else3(void **state) "{% else %}\n" "{% else %}\n"; bc_error_t *err = NULL; - bc_slist_t *stmts = blogc_template_parse(a, strlen(a), &err); + bc_slist_t *ast = blogc_template_parse(a, strlen(a), &err); assert_non_null(err); - assert_null(stmts); + assert_null(ast); assert_int_equal(err->type, BLOGC_ERROR_TEMPLATE_PARSER); assert_string_equal(err->msg, "More than one 'else' statement for an open 'if', 'ifdef' or 'ifndef' " @@ -943,9 +943,9 @@ test_template_parse_invalid_block_end(void **state) { const char *a = "{% block entry }}\n"; bc_error_t *err = NULL; - bc_slist_t *stmts = blogc_template_parse(a, strlen(a), &err); + bc_slist_t *ast = blogc_template_parse(a, strlen(a), &err); assert_non_null(err); - assert_null(stmts); + assert_null(ast); assert_int_equal(err->type, BLOGC_ERROR_TEMPLATE_PARSER); assert_string_equal(err->msg, "Invalid statement syntax. Must end with '%}'.\n" @@ -959,9 +959,9 @@ test_template_parse_invalid_variable_name(void **state) { const char *a = "{% block entry %}{{ bola }}{% endblock %}\n"; bc_error_t *err = NULL; - bc_slist_t *stmts = blogc_template_parse(a, strlen(a), &err); + bc_slist_t *ast = blogc_template_parse(a, strlen(a), &err); assert_non_null(err); - assert_null(stmts); + assert_null(ast); assert_int_equal(err->type, BLOGC_ERROR_TEMPLATE_PARSER); assert_string_equal(err->msg, "Invalid variable name. Must begin with uppercase letter.\n" @@ -976,9 +976,9 @@ test_template_parse_invalid_variable_name2(void **state) { const char *a = "{% block entry %}{{ Bola }}{% endblock %}\n"; bc_error_t *err = NULL; - bc_slist_t *stmts = blogc_template_parse(a, strlen(a), &err); + bc_slist_t *ast = blogc_template_parse(a, strlen(a), &err); assert_non_null(err); - assert_null(stmts); + assert_null(ast); assert_int_equal(err->type, BLOGC_ERROR_TEMPLATE_PARSER); assert_string_equal(err->msg, "Invalid variable name. Must be uppercase letter, number or '_'.\n" @@ -993,9 +993,9 @@ test_template_parse_invalid_variable_name3(void **state) { const char *a = "{% block entry %}{{ 0123 }}{% endblock %}\n"; bc_error_t *err = NULL; - bc_slist_t *stmts = blogc_template_parse(a, strlen(a), &err); + bc_slist_t *ast = blogc_template_parse(a, strlen(a), &err); assert_non_null(err); - assert_null(stmts); + assert_null(ast); assert_int_equal(err->type, BLOGC_ERROR_TEMPLATE_PARSER); assert_string_equal(err->msg, "Invalid variable name. Must begin with uppercase letter.\n" @@ -1010,9 +1010,9 @@ test_template_parse_invalid_variable_end(void **state) { const char *a = "{% block entry %}{{ BOLA %}{% endblock %}\n"; bc_error_t *err = NULL; - bc_slist_t *stmts = blogc_template_parse(a, strlen(a), &err); + bc_slist_t *ast = blogc_template_parse(a, strlen(a), &err); assert_non_null(err); - assert_null(stmts); + assert_null(ast); assert_int_equal(err->type, BLOGC_ERROR_TEMPLATE_PARSER); assert_string_equal(err->msg, "Invalid statement syntax. Must end with '}}'.\n" @@ -1027,9 +1027,9 @@ test_template_parse_invalid_close(void **state) { const char *a = "{% block entry %%\n"; bc_error_t *err = NULL; - bc_slist_t *stmts = blogc_template_parse(a, strlen(a), &err); + bc_slist_t *ast = blogc_template_parse(a, strlen(a), &err); assert_non_null(err); - assert_null(stmts); + assert_null(ast); assert_int_equal(err->type, BLOGC_ERROR_TEMPLATE_PARSER); assert_string_equal(err->msg, "Invalid statement syntax. Must end with '}'.\n" @@ -1043,9 +1043,9 @@ test_template_parse_invalid_close2(void **state) { const char *a = "{% block entry %}{{ BOLA }%{% endblock %}\n"; bc_error_t *err = NULL; - bc_slist_t *stmts = blogc_template_parse(a, strlen(a), &err); + bc_slist_t *ast = blogc_template_parse(a, strlen(a), &err); assert_non_null(err); - assert_null(stmts); + assert_null(ast); assert_int_equal(err->type, BLOGC_ERROR_TEMPLATE_PARSER); assert_string_equal(err->msg, "Invalid statement syntax. Must end with '}'.\n" @@ -1060,9 +1060,9 @@ test_template_parse_invalid_endif_not_closed(void **state) { const char *a = "{% block entry %}{% endblock %}{% ifdef BOLA %}\n"; bc_error_t *err = NULL; - bc_slist_t *stmts = blogc_template_parse(a, strlen(a), &err); + bc_slist_t *ast = blogc_template_parse(a, strlen(a), &err); assert_non_null(err); - assert_null(stmts); + assert_null(ast); assert_int_equal(err->type, BLOGC_ERROR_TEMPLATE_PARSER); assert_string_equal(err->msg, "1 open 'if', 'ifdef' and/or 'ifndef' statements " "were not closed!"); @@ -1075,9 +1075,9 @@ test_template_parse_invalid_endif_not_closed_inside_block(void **state) { const char *a = "{% block listing %}{% ifdef BOLA %}{% endblock %}{% endif %}"; bc_error_t *err = NULL; - bc_slist_t *stmts = blogc_template_parse(a, strlen(a), &err); + bc_slist_t *ast = blogc_template_parse(a, strlen(a), &err); assert_non_null(err); - assert_null(stmts); + assert_null(ast); assert_int_equal(err->type, BLOGC_ERROR_TEMPLATE_PARSER); assert_string_equal(err->msg, "1 open 'if', 'ifdef' and/or 'ifndef' statements were not closed inside " @@ -1091,9 +1091,9 @@ test_template_parse_invalid_else_not_closed_inside_block(void **state) { const char *a = "{% block listing %}{% ifdef BOLA %}{% else %}{% endblock %}{% endif %}"; bc_error_t *err = NULL; - bc_slist_t *stmts = blogc_template_parse(a, strlen(a), &err); + bc_slist_t *ast = blogc_template_parse(a, strlen(a), &err); assert_non_null(err); - assert_null(stmts); + assert_null(ast); assert_int_equal(err->type, BLOGC_ERROR_TEMPLATE_PARSER); assert_string_equal(err->msg, "1 open 'if', 'ifdef' and/or 'ifndef' statements were not closed inside " @@ -1107,9 +1107,9 @@ test_template_parse_invalid_block_not_closed(void **state) { const char *a = "{% block entry %}\n"; bc_error_t *err = NULL; - bc_slist_t *stmts = blogc_template_parse(a, strlen(a), &err); + bc_slist_t *ast = blogc_template_parse(a, strlen(a), &err); assert_non_null(err); - assert_null(stmts); + assert_null(ast); assert_int_equal(err->type, BLOGC_ERROR_TEMPLATE_PARSER); assert_string_equal(err->msg, "An open block was not closed!"); bc_error_free(err); @@ -1121,9 +1121,9 @@ test_template_parse_invalid_foreach_not_closed(void **state) { const char *a = "{% foreach ASD %}\n"; bc_error_t *err = NULL; - bc_slist_t *stmts = blogc_template_parse(a, strlen(a), &err); + bc_slist_t *ast = blogc_template_parse(a, strlen(a), &err); assert_non_null(err); - assert_null(stmts); + assert_null(ast); assert_int_equal(err->type, BLOGC_ERROR_TEMPLATE_PARSER); assert_string_equal(err->msg, "An open 'foreach' statement was not closed!"); bc_error_free(err); -- cgit v1.2.3-18-g5258