Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Added unit tests for add filter

  • Loading branch information...
commit 7c29274f0957c58148cd239a138f2856da162e85 1 parent 6623540
@srstrong authored
Showing with 21 additions and 3 deletions.
  1. +21 −3 tests/src/erlydtl_unittests.erl
View
24 tests/src/erlydtl_unittests.erl
@@ -366,9 +366,27 @@ tests() ->
{"Escape is applied last",
<<"{{ var1|escape|linebreaksbr }}">>, [{var1, <<"\n">>}],
<<"&lt;br /&gt;">>},
- {"|add:4",
- <<"{{ one|add:4 }}">>, [{one, "1"}],
- <<"5">>},
+ {"add; lhs number, rhs number",
+ <<"{{ one|add:4}}">>, [{one, 1}],
+ <<"5">>},
+ {"add; lhs numeric string, rhs number",
+ <<"{{ one|add:4}}">>, [{one, "1"}],
+ <<"5">>},
+ {"add; lhs number, rhs numeric string",
+ <<"{{ one|add:'4'}}">>, [{one, 1}],
+ <<"5">>},
+ {"add; lhs non-numeric string, rhs number",
+ <<"{{ one|add:4}}">>, [{one, "foo"}],
+ <<"foo4">>},
+ {"add; lhs number, rhs non-numeric string",
+ <<"{{ one|add:'foo'}}">>, [{one, 1}],
+ <<"1foo">>},
+ {"add; lhs non-numeric string, rhs non-numeric string",
+ <<"{{ one|add:'bar'}}">>, [{one, "foo"}],
+ <<"foobar">>},
+ {"add; lhs numeric string, rhs numeric string",
+ <<"{{ one|add:'4'}}">>, [{one, "1"}],
+ <<"5">>},
{"|addslashes",
<<"{{ var1|addslashes }}">>, [{var1, "Jimmy's \"great\" meats'n'things"}],
<<"Jimmy\\'s \\\"great\\\" meats\\'n\\'things">>},
Please sign in to comment.
Something went wrong with that request. Please try again.