File: 04register.t

package info (click to toggle)
libhtml-template-pro-perl 0.9524-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 1,512 kB
  • sloc: ansic: 1,841; perl: 1,474; yacc: 404; pascal: 118; makefile: 6
file content (25 lines) | stat: -rw-r--r-- 734 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
use Test::More tests => 3;
use HTML::Template::Pro;

HTML::Template::Expr->register_function(directory_exists => sub {
					  my $dir = shift;
					  return -d $dir;
					});
HTML::Template::Expr->register_function(commify => sub {
					  local $_ = shift;
					  1 while s/^([-+]?\d+)(\d{3})/$1,$2/;
					  return $_;
					});

my $template = HTML::Template::Expr->new(path => ['t/templates'],
                                      filename => 'register.tmpl',
                                     );
my $output = $template->output;
like $output, qr/^OK/, 'directory_exists()';
like $output, qr/2,000/, 'comify';

eval {
  HTML::Template::Expr->register_function('foo', 'bar');
};
like $@, qr/must be subroutine ref/, 'type check';