VirtualBox

source: vbox/trunk/src/libs/openssl-3.0.1/external/perl/Text-Template-1.46/t/08-exported.t@ 94081

Last change on this file since 94081 was 91772, checked in by vboxsync, 4 years ago

openssl-1.1.1l: Applied and adjusted our OpenSSL changes to 1.1.1l. bugref:10126

File size: 2.2 KB
Line 
1#!perl
2#
3# test apparatus for Text::Template module
4# still incomplete.
5
6use Text::Template 'fill_in_file', 'fill_in_string';
7
8die "This is the test program for Text::Template version 1.46.
9You are using version $Text::Template::VERSION instead.
10That does not make sense.\n
11Aborting"
12 unless $Text::Template::VERSION == 1.46;
13
14print "1..6\n";
15
16$n=1;
17$Q::n = $Q::n = 119;
18
19# (1) Test fill_in_string
20$out = fill_in_string('The value of $n is {$n}.', PACKAGE => 'Q' );
21print +($out eq 'The value of $n is 119.' ? '' : 'not '), "ok $n\n";
22$n++;
23
24# (2) Test fill_in_file
25$TEMPFILE = "tt$$";
26open F, "> $TEMPFILE" or die "Couldn't open test file: $!; aborting";
27print F 'The value of $n is {$n}.', "\n";
28close F or die "Couldn't write test file: $!; aborting";
29$R::n = $R::n = 8128;
30
31$out = fill_in_file($TEMPFILE, PACKAGE => 'R');
32print +($out eq "The value of \$n is 8128.\n" ? '' : 'not '), "ok $n\n";
33$n++;
34
35# (3) Jonathan Roy reported this bug:
36open F, "> $TEMPFILE" or die "Couldn't open test file: $!; aborting";
37print F "With a message here? [% \$var %]\n";
38close F or die "Couldn't close test file: $!; aborting";
39$out = fill_in_file($TEMPFILE, DELIMITERS => ['[%', '%]'],
40 HASH => { "var" => \"It is good!" });
41print +($out eq "With a message here? It is good!\n" ? '' : 'not '), "ok $n\n";
42$n++;
43
44# (4) It probably occurs in fill_this_in also:
45$out =
46 Text::Template->fill_this_in("With a message here? [% \$var %]\n",
47 DELIMITERS => ['[%', '%]'],
48 HASH => { "var" => \"It is good!" });
49print +($out eq "With a message here? It is good!\n" ? '' : 'not '), "ok $n\n";
50$n++;
51
52# (5) This test failed in 1.25. It was supplied by Donald L. Greer Jr.
53# Note that it's different from (1) in that there's no explicit
54# package=> argument.
55use vars qw($string $foo $r);
56$string='Hello {$foo}';
57$foo="Don";
58$r = fill_in_string($string);
59print (($r eq 'Hello Don' ? '' : 'not '), 'ok ', $n++, "\n");
60
61# (6) This test failed in 1.25. It's a variation on (5)
62package Q2;
63use Text::Template 'fill_in_string';
64use vars qw($string $foo $r);
65$string='Hello {$foo}';
66$foo="Don";
67$r = fill_in_string($string);
68print (($r eq 'Hello Don' ? '' : 'not '), 'ok ', $main::n++, "\n");
69
70package main;
71
72END { $TEMPFILE && unlink $TEMPFILE }
73
74exit;
75
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