Skip to content

Commit

Permalink
Merge pull request #36 from amiri/master
Browse files Browse the repository at this point in the history
  • Loading branch information
abw committed Apr 24, 2014
2 parents 02bfb1f + a2b2110 commit 3ba3ccf
Show file tree
Hide file tree
Showing 4 changed files with 82 additions and 11 deletions.
9 changes: 5 additions & 4 deletions Makefile.PL
Original file line number Diff line number Diff line change
Expand Up @@ -146,10 +146,11 @@ my %opts = (
'PMLIBDIRS' => [ 'lib' ],
'DIR' => [ ],
'PREREQ_PM' => {
'AppConfig' => $TT_APPCONFIG_VERSION,
'File::Spec' => $TT_FILE_SPEC_VERSION,
'File::Temp' => $TT_FILE_TEMP_VERSION,
'Scalar::Util' => 0,
'AppConfig' => $TT_APPCONFIG_VERSION,
'File::Spec' => $TT_FILE_SPEC_VERSION,
'File::Temp' => $TT_FILE_TEMP_VERSION,
'Scalar::Util' => 0,
'Test::LeakTrace' => 0,
},
'META_MERGE' => {
'resources' => {
Expand Down
10 changes: 5 additions & 5 deletions lib/Template/Manual/Credits.pod
Original file line number Diff line number Diff line change
Expand Up @@ -76,11 +76,11 @@ the Template Toolkit. Their efforts continue to be very much appreciated.
Please let me know if you think anyone is missing from this list.
Chuck Adams, Stephen Adkins, Ivan Adzhubey, Mark Anderson, Bradley Baetz,
Thierry-Michel Barral, Craig Barratt, Stas Bekman, Robin Berjon, Tony Bowden,
Neil Bowers, Leon Brocard, Lyle Brooks, Norbert Buchmüller, Dave Cash, Piers
Cawley, Darren Chamberlain, Timmy Chan, Eric Cholet, Chromatic, Nik Clayton,
Tosh Cooey, Dave Cross, Chris Dean, Francois Desarmenien, Horst Dumcke, Mark
Fowler, Michael Fowler, Kenny Gatdula, Axel Gerstmair, Jay Hannah, Dylan
Amiri Barksdale, Thierry-Michel Barral, Craig Barratt, Stas Bekman, Robin Berjon,
Tony Bowden, Neil Bowers, Leon Brocard, Lyle Brooks, Norbert Buchmüller,
Dave Cash, Piers Cawley, Darren Chamberlain, Timmy Chan, Eric Cholet, Chromatic,
Nik Clayton, Tosh Cooey, Dave Cross, Chris Dean, Francois Desarmenien, Horst Dumcke,
Mark Fowler, Michael Fowler, Kenny Gatdula, Axel Gerstmair, Jay Hannah, Dylan
William Hardison, Perrin Harkins, Bryce Harrington, Dave Hodgkinson, Lubomir
Host, Dave Howorth, Jon Jensen, Harald Joerg, Colin Johnson, Colin Keith,
Adam Kennedy, Vivek Khera, Alexey A. Kiritchun, Rafael Kitover, Andreas
Expand Down
4 changes: 2 additions & 2 deletions lib/Template/Plugin/Filter.pm
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ sub factory {
# weaken($this);

if ($self->{ _DYNAMIC }) {
return $self->{ _DYNAMIC_FILTER } ||= [ sub {
return [ sub {
my ($context, @args) = @_;
my $config = ref $args[-1] eq 'HASH' ? pop(@args) : { };

Expand All @@ -84,7 +84,7 @@ sub factory {
}, 1 ];
}
else {
return $self->{ _STATIC_FILTER } ||= sub {
return sub {
$this->filter(shift);
};
}
Expand Down
70 changes: 70 additions & 0 deletions t/plugin_leaks.t
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
#============================================================= -*-perl-*-
#
# t/plugin_leaks.t
#
# Test the Template::Plugins module.
#
# Written by Andy Wardley <abw@kfs.org>
#
# Copyright (C) 1996-2000 Andy Wardley. All Rights Reserved.
# Copyright (C) 1998-2000 Canon Research Centre Europe Ltd.
#
# This is free software; you can redistribute it and/or modify it
# under the same terms as Perl itself.
#
# $Id$
#
#========================================================================

use strict;
use lib qw( t/lib ./lib ../lib ../blib/arch );
use Template::Test;
use Template::Plugins;
use Template::Constants qw( :debug );
use Test::LeakTrace;
use Cwd qw( abs_path );
$^W = 1;
my $DEBUG = grep(/^--?d(debug)?$/, @ARGV);

ntests(2);

my $dir = abs_path(-d 't' ? 't/test/plugin' : 'test/plugin');
my $src = abs_path(-d 't' ? 't/test/lib' : 'test/lib');
unshift(@INC, $dir);

my ($input, $output);
my $output = '';

# Copy input parsing from Template::Test::test_expect
eval {
local $/ = undef;
$input = <DATA>;
};

$input =~ s/^#.*?\n//gm;
$input = $' if $input =~ /\s*--\s*start\s*--\s*/;
$input = $` if $input =~ /\s*--\s*stop\s*--\s*/;


# Declare a processor
my $tt1 = Template->new({
PLUGIN_BASE => [ 'MyPlugs', 'Template::Plugin' ],
INCLUDE_PATH => $src,
DEBUG => $DEBUG ? DEBUG_PLUGINS : 0,
}) || die Template->error();

# Check whether processing with a double-included filter produces more than 4 leaks.
leaks_cmp_ok {
$tt1->process(\$input, {}, \$output);
} '<', 4;

# There should be none at all here.
no_leaks_ok {
$tt1->process(\$input, {}, \$output);
} "No leaks at all";

__END__
[% USE Simple -%]
[% 'world' | simple %]
[% INCLUDE simple2 %]
[% 'hello' | simple %]

0 comments on commit 3ba3ccf

Please sign in to comment.