VirtualBox

source: vbox/trunk/src/libs/openssl-3.0.7/external/perl/Text-Template-1.56/t/broken.t@ 100620

Last change on this file since 100620 was 94320, checked in by vboxsync, 3 years ago

libs/openssl-3.0.1: Export to OSE and fix copyright headers in Makefiles, bugref:10128

File size: 1.6 KB
Line 
1#!perl
2# test apparatus for Text::Template module
3
4use strict;
5use warnings;
6use Test::More tests => 7;
7
8use_ok 'Text::Template' or exit 1;
9
10# (1) basic error delivery
11{
12 my $r = Text::Template->new(
13 TYPE => 'string',
14 SOURCE => '{1/0}',)->fill_in();
15 is $r, q{Program fragment delivered error ``Illegal division by zero at template line 1.''};
16}
17
18# (2) BROKEN sub called in ->new?
19{
20 my $r = Text::Template->new(
21 TYPE => 'string',
22 SOURCE => '{1/0}',
23 BROKEN => sub { '---' },)->fill_in();
24 is $r, q{---};
25}
26
27# (3) BROKEN sub called in ->fill_in?
28{
29 my $r = Text::Template->new(
30 TYPE => 'string',
31 SOURCE => '{1/0}',)->fill_in(BROKEN => sub { '---' });
32 is $r, q{---};
33}
34
35# (4) BROKEN sub passed correct args when called in ->new?
36{
37 my $r = Text::Template->new(
38 TYPE => 'string',
39 SOURCE => '{1/0}',
40 BROKEN => sub {
41 my %a = @_;
42 qq{$a{lineno},$a{error},$a{text}};
43 },)->fill_in();
44 is $r, qq{1,Illegal division by zero at template line 1.\n,1/0};
45}
46
47# (5) BROKEN sub passed correct args when called in ->fill_in?
48{
49 my $r = Text::Template->new(
50 TYPE => 'string',
51 SOURCE => '{1/0}',
52 )->fill_in(
53 BROKEN => sub {
54 my %a = @_;
55 qq{$a{lineno},$a{error},$a{text}};
56 });
57 is $r, qq{1,Illegal division by zero at template line 1.\n,1/0};
58}
59
60# BROKEN sub handles undef
61{
62 my $r = Text::Template->new(TYPE => 'string', SOURCE => 'abc{1/0}defg')
63 ->fill_in(BROKEN => sub { undef });
64
65 is $r, 'abc';
66}
Note: See TracBrowser for help on using the repository browser.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette