VirtualBox

source: vbox/trunk/src/libs/openssl-1.1.1f/external/perl/Text-Template-1.46/t/14-broken.t@ 83531

Last change on this file since 83531 was 83531, checked in by vboxsync, 5 years ago

setting svn:sync-process=export for openssl-1.1.1f, all files except tests

File size: 2.3 KB
Line 
1#!perl
2# test apparatus for Text::Template module
3
4use Text::Template;
5
6print "1..5\n";
7
8$n=1;
9
10die "This is the test program for Text::Template version 1.46.
11You are using version $Text::Template::VERSION instead.
12That does not make sense.\n
13Aborting"
14 unless $Text::Template::VERSION == 1.46;
15
16# (1) basic error delivery
17{ my $r = Text::Template->new(TYPE => 'string',
18 SOURCE => '{1/0}',
19 )->fill_in();
20 if ($r eq q{Program fragment delivered error ``Illegal division by zero at template line 1.''}) {
21 print "ok $n\n";
22 } else {
23 print "not ok $n\n# $r\n";
24 }
25 $n++;
26}
27
28# (2) BROKEN sub called in ->new?
29{ my $r = Text::Template->new(TYPE => 'string',
30 SOURCE => '{1/0}',
31 BROKEN => sub {'---'},
32 )->fill_in();
33 if ($r eq q{---}) {
34 print "ok $n\n";
35 } else {
36 print "not ok $n\n# $r\n";
37 }
38 $n++;
39}
40
41# (3) BROKEN sub called in ->fill_in?
42{ my $r = Text::Template->new(TYPE => 'string',
43 SOURCE => '{1/0}',
44 )->fill_in(BROKEN => sub {'---'});
45 if ($r eq q{---}) {
46 print "ok $n\n";
47 } else {
48 print "not ok $n\n# $r\n";
49 }
50 $n++;
51}
52
53# (4) BROKEN sub passed correct args when called in ->new?
54{ my $r = Text::Template->new(TYPE => 'string',
55 SOURCE => '{1/0}',
56 BROKEN => sub { my %a = @_;
57 qq{$a{lineno},$a{error},$a{text}}
58 },
59 )->fill_in();
60 if ($r eq qq{1,Illegal division by zero at template line 1.\n,1/0}) {
61 print "ok $n\n";
62 } else {
63 print "not ok $n\n# $r\n";
64 }
65 $n++;
66}
67
68# (5) BROKEN sub passed correct args when called in ->fill_in?
69{ my $r = Text::Template->new(TYPE => 'string',
70 SOURCE => '{1/0}',
71 )->fill_in(BROKEN =>
72 sub { my %a = @_;
73 qq{$a{lineno},$a{error},$a{text}}
74 });
75 if ($r eq qq{1,Illegal division by zero at template line 1.\n,1/0}) {
76 print "ok $n\n";
77 } else {
78 print "not ok $n\n# $r\n";
79 }
80 $n++;
81}
82
Note: See TracBrowser for help on using the repository browser.

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