Permalink
Browse files

Move tests to a separate file

  • Loading branch information...
1 parent 3b00210 commit 6fa88e7decf53c3413a92824281e9a1e2f861a43 @pusewicz pusewicz committed Aug 11, 2012
Showing with 40 additions and 18 deletions.
  1. +0 −18 src/mustache.erl
  2. +40 −0 test/mustache_tests.erl
View
@@ -31,10 +31,6 @@
section_re = undefined,
tag_re = undefined}).
--ifdef(TEST).
--include_lib("eunit/include/eunit.hrl").
--endif.
-
compile(Body) when is_list(Body) ->
State = #mstate{},
CompiledTemplate = pre_compile(Body, State),
@@ -218,17 +214,3 @@ escape([X | Rest], Acc) ->
start([T]) ->
Out = render(list_to_atom(T)),
io:format(Out ++ "~n", []).
-
--ifdef(TEST).
-
-simple_test() ->
- Ctx = dict:from_list([{name, "world"}]),
- Result = render("Hello {{name}}!", Ctx),
- ?assertEqual("Hello world!", Result).
-
-integer_values_too_test() ->
- Ctx = dict:from_list([{name, "Chris"}, {value, 10000}]),
- Result = render("Hello {{name}}~nYou have just won ${{value}}!", Ctx),
- ?assertEqual("Hello Chris~nYou have just won $10000!", Result).
-
--endif.
View
@@ -0,0 +1,40 @@
+%% The MIT License
+%%
+%% Copyright (c) 2009 Tom Preston-Werner <tom@mojombo.com>
+%%
+%% Permission is hereby granted, free of charge, to any person obtaining a copy
+%% of this software and associated documentation files (the "Software"), to deal
+%% in the Software without restriction, including without limitation the rights
+%% to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+%% copies of the Software, and to permit persons to whom the Software is
+%% furnished to do so, subject to the following conditions:
+%%
+%% The above copyright notice and this permission notice shall be included in
+%% all copies or substantial portions of the Software.
+%%
+%% THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+%% IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+%% FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+%% AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+%% LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+%% OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+%% THE SOFTWARE.
+
+%% See the README at http://github.com/mojombo/mustache.erl for additional
+%% documentation and usage examples.
+
+-module(mustache_tests).
+
+-compile(export_all).
+
+-include_lib("eunit/include/eunit.hrl").
+
+simple_test() ->
+ Ctx = dict:from_list([{name, "world"}]),
+ Result = mustache:render("Hello {{name}}!", Ctx),
+ ?assertEqual("Hello world!", Result).
+
+integer_values_too_test() ->
+ Ctx = dict:from_list([{name, "Chris"}, {value, 10000}]),
+ Result = mustache:render("Hello {{name}}~nYou have just won ${{value}}!", Ctx),
+ ?assertEqual("Hello Chris~nYou have just won $10000!", Result).

0 comments on commit 6fa88e7

Please sign in to comment.