diff options
author | Rafael G. Martins <rafael@rafaelmartins.eng.br> | 2015-05-08 21:41:53 -0300 |
---|---|---|
committer | Rafael G. Martins <rafael@rafaelmartins.eng.br> | 2015-05-08 21:41:53 -0300 |
commit | 0a63da7081bd1227c5788000349cf7ac03f8e107 (patch) | |
tree | c03b15440a99a113ecc69905199b3a527c9cbd1b /tests/check_renderer.c | |
parent | b24efa3885637d953892ccf718662aa693eaa879 (diff) | |
download | blogc-0a63da7081bd1227c5788000349cf7ac03f8e107.tar.gz blogc-0a63da7081bd1227c5788000349cf7ac03f8e107.tar.bz2 blogc-0a63da7081bd1227c5788000349cf7ac03f8e107.zip |
renderer: respect local scope
Diffstat (limited to 'tests/check_renderer.c')
-rw-r--r-- | tests/check_renderer.c | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/tests/check_renderer.c b/tests/check_renderer.c index 1d3c205..3d8a205 100644 --- a/tests/check_renderer.c +++ b/tests/check_renderer.c @@ -331,6 +331,38 @@ test_render_prefer_local_variable(void **state) static void +test_render_respect_variable_scope(void **state) +{ + const char *str = + "{{ LOL }}\n" + "{{ BOLA }}\n" + "{% block entry %}\n" + "{% if LOL %}{{ LOL }}{% endif %}\n" + "{% if BOLA %}{{ BOLA }}{% endif %}\n" + "{% endblock %}\n"; + blogc_error_t *err = NULL; + b_slist_t *l = blogc_template_parse(str, strlen(str), &err); + assert_non_null(l); + assert_null(err); + b_slist_t *s = create_sources(1); + assert_non_null(s); + b_trie_t *c = b_trie_new(free); + char *out = blogc_render(l, s, c, false); + assert_string_equal(out, + "\n" + "\n" + "\n" + "\n" + "asd\n" + "\n"); + b_trie_free(c); + blogc_template_free_stmts(l); + b_slist_free_full(s, (b_free_func_t) b_trie_free); + free(out); +} + + +static void test_get_variable(void **state) { b_trie_t *g = b_trie_new(free); @@ -446,6 +478,7 @@ main(void) unit_test(test_render_outside_block), unit_test(test_render_null), unit_test(test_render_prefer_local_variable), + unit_test(test_render_respect_variable_scope), unit_test(test_get_variable), unit_test(test_get_variable_only_local), unit_test(test_get_variable_only_global), |