X-Git-Url: https://git.dogcows.com/gitweb?a=blobdiff_plain;f=t%2F7_template_00_base.t;h=7fa643b5c0ac333018d9cd3569fa824110a56427;hb=d0287461de3f9b5c49ce02b22957022bdc5e87d8;hp=48472ddc3625244cc0f545c9a1ef555713905a9d;hpb=3fe8e76eb82e9d74f656674c5ba913950e166ab1;p=chaz%2Fp5-CGI-Ex diff --git a/t/7_template_00_base.t b/t/7_template_00_base.t index 48472dd..7fa643b 100644 --- a/t/7_template_00_base.t +++ b/t/7_template_00_base.t @@ -14,7 +14,7 @@ BEGIN { }; use strict; -use Test::More tests => 514 - ($is_tt ? 103 : 0); +use Test::More tests => 515 - ($is_tt ? 103 : 0); use Data::Dumper qw(Dumper); use constant test_taint => 0 && eval { require Taint::Runtime }; @@ -306,7 +306,7 @@ process_ok("[% 123.2.length %]" => 5) if ! $is_tt; process_ok("[% -123.2.length %]" => -5) if ! $is_tt; # the - doesn't bind as tight as the dot methods process_ok("[% (-123.2).length %]" => 6) if ! $is_tt; process_ok("[% a = 23; a.0 %]" => 23) if ! $is_tt; # '0' is a scalar_op -process_ok('[% 1.rand %]' => qr/^0\.\d+$/) if ! $is_tt; +process_ok('[% 1.rand %]' => qr/^0\.\d+(?:e-?\d+)?$/) if ! $is_tt; process_ok("[% n.repeat %]" => '1', {n => 1}) if ! $is_tt; # tt2 virtual method defaults to 0 process_ok("[% n.repeat(0) %]" => '', {n => 1}); @@ -350,16 +350,16 @@ process_ok('[% ["a".."z"].${ 26.rand } %]' => qr/^[a-z]/) if ! $is_tt; process_ok("[% ' ' | uri %]" => '%20'); -process_ok('[% "one".as %]' => "one") if ! $is_tt; -process_ok('[% 2.as("%02d") %]' => "02") if ! $is_tt; +process_ok('[% "one".fmt %]' => "one") if ! $is_tt; +process_ok('[% 2.fmt("%02d") %]' => "02") if ! $is_tt; -process_ok('[% [1..3].as %]' => "1 2 3") if ! $is_tt; -process_ok('[% [1..3].as("%02d") %]' => '01 02 03') if ! $is_tt; -process_ok('[% [1..3].as("%s", ", ") %]' => '1, 2, 3') if ! $is_tt; +process_ok('[% [1..3].fmt %]' => "1 2 3") if ! $is_tt; +process_ok('[% [1..3].fmt("%02d") %]' => '01 02 03') if ! $is_tt; +process_ok('[% [1..3].fmt("%s", ", ") %]' => '1, 2, 3') if ! $is_tt; -process_ok('[% {a => "B", c => "D"}.as %]' => "a\tB\nc\tD") if ! $is_tt; -process_ok('[% {a => "B", c => "D"}.as("%s:%s") %]' => "a:B\nc:D") if ! $is_tt; -process_ok('[% {a => "B", c => "D"}.as("%s:%s", "; ") %]' => "a:B; c:D") if ! $is_tt; +process_ok('[% {a => "B", c => "D"}.fmt %]' => "a\tB\nc\tD") if ! $is_tt; +process_ok('[% {a => "B", c => "D"}.fmt("%s:%s") %]' => "a:B\nc:D") if ! $is_tt; +process_ok('[% {a => "B", c => "D"}.fmt("%s:%s", "; ") %]' => "a:B; c:D") if ! $is_tt; ###----------------------------------------------------------------### ### virtual objects @@ -374,7 +374,7 @@ process_ok('[% a = Hash.new("one", "ONE") %][% a.one %]' => 'ONE') if ! $is_tt; process_ok('[% a = Hash.new(one = "ONE") %][% a.one %]' => 'ONE') if ! $is_tt; process_ok('[% a = Hash.new(one => "ONE") %][% a.one %]' => 'ONE') if ! $is_tt; -process_ok('[% {a => 1, b => 2} | Hash.keys | List.join(", ") %]' => 'a, b'); +process_ok('[% {a => 1, b => 2} | Hash.keys | List.join(", ") %]' => 'a, b') if ! $is_tt; ###----------------------------------------------------------------### ### chomping @@ -729,6 +729,9 @@ process_ok("[% USE d.d = Foo(bar = 'baz') %]one[% d.d.bar %]" => '', {tt_config process_ok("[% USE a(bar = 'baz') %]one[% a.seven %]" => '', {tt_config => [@config_p, PLUGINS => {a=>'Foo'}, ]}); process_ok("[% USE a(bar = 'baz') %]one[% a.seven %]" => 'one7', {tt_config => [@config_p, PLUGINS => {a=>'Foo2'},]}); +@config_p = (PLUGIN_BASE => ['NonExistant', 'MyTestPlugin'], LOAD_PERL => 1); +process_ok("[% USE Foo %]one" => 'one', {tt_config => \@config_p}); + ###----------------------------------------------------------------### ### macro