2 # test apparatus for Text::Template module
6 use Test::More tests => 7;
8 use_ok 'Text::Template' or exit 1;
10 # (1) basic error delivery
12 my $r = Text::Template->new(
14 SOURCE => '{1/0}',)->fill_in();
15 is $r, q{Program fragment delivered error ``Illegal division by zero at template line 1.''};
18 # (2) BROKEN sub called in ->new?
20 my $r = Text::Template->new(
23 BROKEN => sub { '---' },)->fill_in();
27 # (3) BROKEN sub called in ->fill_in?
29 my $r = Text::Template->new(
31 SOURCE => '{1/0}',)->fill_in(BROKEN => sub { '---' });
35 # (4) BROKEN sub passed correct args when called in ->new?
37 my $r = Text::Template->new(
42 qq{$a{lineno},$a{error},$a{text}};
44 is $r, qq{1,Illegal division by zero at template line 1.\n,1/0};
47 # (5) BROKEN sub passed correct args when called in ->fill_in?
49 my $r = Text::Template->new(
55 qq{$a{lineno},$a{error},$a{text}};
57 is $r, qq{1,Illegal division by zero at template line 1.\n,1/0};
60 # BROKEN sub handles undef
62 my $r = Text::Template->new(TYPE => 'string', SOURCE => 'abc{1/0}defg')
63 ->fill_in(BROKEN => sub { undef });