<commit_before>-module(erlydtl_test_defs).

-export([tests/0]).
-include("testrunner.hrl").
-record(testrec, {foo, bar, baz}).

%% {Name, DTL, Vars, Output}
%% {Name, DTL, Vars, RenderOpts, Output}
%% {Name, DTL, Vars, RenderOpts, CompilerOpts, Output}
%% {Name, DTL, Vars, RenderOpts, CompilerOpts, Output, Warnings}

tests() ->
    [def_to_test(G, D) || {G, Ds} <- all_test_defs(), D <- Ds].

all_test_defs() ->
    [{"vars",
      [{"string",
        <<"String value is: {{ var1 }}">>,
        [{var1, "foo"}], <<"String value is: foo">>},
       {"int",
        <<"The magic number is: {{ var1 }}">>,
        [{var1, 42}], <<"The magic number is: 42">>},
       {"float",
        <<"The price of milk is: {{ var1 }}">>,
        [{var1, 0.42}], <<"The price of milk is: 0.42">>},
       {"No spaces",
        <<"{{var1}}">>,
        [{var1, "foo"}], <<"foo">>},
       {"Variable name is a tag name",
        <<"{{ comment }}">>,
        [{comment, "Nice work!"}], <<"Nice work!">>},
       {"list no the attr",
        <<"{{ content.description }}">>,
        [{content, "test"}], <<"">>},
       {"binary no the attr",
        <<"{{ content.description }}">>,
        [{content, <<"test">>}], <<"">>}
      ]},
     {"comment",
      [{"comment block is excised",
        <<"bob {% comment %}(moron){% endcomment %} loblaw">>,
        [], <<"bob  loblaw">>},
       {"inline comment is excised",
        <<"you're {# not #} a very nice person">>,
        [], <<"you're  a very nice person">>}
      ]},
     {"autoescape",
      [{"Autoescape works",<commit_msg>add test for maps<commit_after>-module(erlydtl_test_defs).

-export([tests/0]).
-include("testrunner.hrl").
-record(testrec, {foo, bar, baz}).

%% {Name, DTL, Vars, Output}
%% {Name, DTL, Vars, RenderOpts, Output}
%% {Name, DTL, Vars, RenderOpts, CompilerOpts, Output}
%% {Name, DTL, Vars, RenderOpts, CompilerOpts, Output, Warnings}

tests() ->
    [def_to_test(G, D) || {G, Ds} <- all_test_defs(), D <- Ds].

-define(IF_MAPS(Then, Else),
        case erlang:is_builtin(erlang, is_map, 1) of
            true -> Then;
            false -> Else
        end).

all_test_defs() ->
    Vars = [{"string",
             <<"String value is: {{ var1 }}">>,
             [{var1, "foo"}], <<"String value is: foo">>},
            {"int",
             <<"The magic number is: {{ var1 }}">>,
             [{var1, 42}], <<"The magic number is: 42">>},
            {"float",
             <<"The price of milk is: {{ var1 }}">>,
             [{var1, 0.42}], <<"The price of milk is: 0.42">>},
            {"No spaces",
             <<"{{var1}}">>,
             [{var1, "foo"}], <<"foo">>},
            {"Variable name is a tag name",
             <<"{{ comment }}">>,
             [{comment, "Nice work!"}], <<"Nice work!">>},
            {"list no the attr",
             <<"{{ content.description }}">>,
             [{content, "test"}], <<"">>},
            {"binary no the attr",
             <<"{{ content.description }}">>,
             [{content, <<"test">>}], <<"">>}],
    MapsTests = ?IF_MAPS([{"maps", <<"{{ my_maps.hello }}">>,
                           [{ my_maps, maps:put(hello, "world", maps:new())}],
                           <<"world">>
                          }], []),
    [{"vars", MapsTests ++ Vars},
     {"comment",
      [{"comment block is excised",
        <<"bob {% comment %}(moron){% endcomment %} loblaw">>,
        [], <<"bob  loblaw">>},
       {"inline comment is excised",
        <<"you're {# not #} a very nice person">>,
        [], <<"you're  a very nice person">>}
      ]},
     {"autoescape",
      [{"Autoescape works",
{'fraction_non_alphanumeric': 0.24233213594915723, 'fraction_numerical': 0.010776457584968223, 'mean_word_length': 2.2035398230088497, 'pattern_counts': {'":': 0, '<': 87, '<?xml version=': 0, '>': 89, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3366019', 'n_tokens_mistral': 1283, 'n_tokens_neox': 1259, 'n_words': 305}