Browse Source

Unittests to restrict complex content in blocktrans. #88

Сергей Прохоров 11 years ago
parent
commit
54d673a679
1 changed files with 6 additions and 2 deletions
  1. 6 2
      tests/src/erlydtl_unittests.erl

+ 6 - 2
tests/src/erlydtl_unittests.erl

@@ -1191,8 +1191,12 @@ tests() ->
         [{blocktrans_locales, ["de"]}, {blocktrans_fun, fun("Hello, {{ name }}", "de") -> <<"Guten tag, {{ name }}">> end}], <<"Guten tag, Mr. President">>},
         [{blocktrans_locales, ["de"]}, {blocktrans_fun, fun("Hello, {{ name }}", "de") -> <<"Guten tag, {{ name }}">> end}], <<"Guten tag, Mr. President">>},
        {"blocktrans with args",
        {"blocktrans with args",
         <<"{% blocktrans with var1=foo %}{{ var1 }}{% endblocktrans %}">>, [{foo, "Hello"}], <<"Hello">>},
         <<"{% blocktrans with var1=foo %}{{ var1 }}{% endblocktrans %}">>, [{foo, "Hello"}], <<"Hello">>},
-       %% {"blocktrans complex not allowed - this should fall",
-       %%  <<"{% blocktrans %}Hello{%if user%}, {{ user.name }}{%endif%}!{% endblocktrans %}">>, [], assert-raise-syntax-error}
+       {"blocktrans blocks in content not allowed",
+        <<"{% blocktrans %}Hello{%if name%}, {{ name }}{%endif%}!{% endblocktrans %}">>, [],
+        {error, [error_info([{{1, 24}, erlydtl_parser, ["syntax error before: ",["\"if\""]]}])], []}},
+       {"blocktrans nested variables not allowed",
+        <<"{% blocktrans %}Hello, {{ user.name }}!{% endblocktrans %}">>, [],
+        {error, [error_info([{{1,31}, erlydtl_parser, ["syntax error before: ","'.'"]}])], []}},
        {"blocktrans runtime",
        {"blocktrans runtime",
         <<"{% blocktrans with v1=foo%}Hello, {{ name }}! See {{v1}}.{%endblocktrans%}">>,
         <<"{% blocktrans with v1=foo%}Hello, {{ name }}! See {{v1}}.{%endblocktrans%}">>,
         [{name, "Mr. President"}, {foo, <<"rubber-duck">>}],
         [{name, "Mr. President"}, {foo, <<"rubber-duck">>}],