Browse Source

Adding tests for the variable lookup using an arity-1 func in the context.

Christian Sunesson 15 years ago
parent
commit
fb6a0a9fcf
1 changed files with 4 additions and 0 deletions
  1. 4 0
      src/tests/erlydtl_unittests.erl

+ 4 - 0
src/tests/erlydtl_unittests.erl

@@ -59,10 +59,14 @@ tests() ->
                     <<"{{ var1 }}">>, dict:store(var1, "bar", dict:new()), <<"bar">>},
                 {"Render variable in gb_tree",
                     <<"{{ var1 }}">>, gb_trees:insert(var1, "bar", gb_trees:empty()), <<"bar">>},
+                {"Render variable in arity-1 func",
+                    <<"I enjoy {{ var1 }}">>, fun (var1) -> "Othello" end, <<"I enjoy Othello">>},
                 {"Render variable with attribute in dict",
                     <<"{{ var1.attr }}">>, [{var1, dict:store(attr, "Othello", dict:new())}], <<"Othello">>},
                 {"Render variable with attribute in gb_tree",
                     <<"{{ var1.attr }}">>, [{var1, gb_trees:insert(attr, "Othello", gb_trees:empty())}], <<"Othello">>},
+                {"Render variable with attribute in arity-1 func",
+                    <<"I enjoy {{ var1.game }}">>, [{var1, fun (game) -> "Othello" end}], <<"I enjoy Othello">>},
                 {"Render variable in parameterized module",
                     <<"{{ var1.some_var }}">>, [{var1, erlydtl_example_variable_storage:new("foo")}], <<"foo">>},
                 {"Nested attributes",