aboutsummaryrefslogtreecommitdiff
path: root/openssl-1.1.0h/external/perl/Text-Template-1.46/t/11-prepend.t
blob: fe242e5898a21073daac87895d4bfa7d58f43449 (plain)
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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
#!perl
#
# Tests for PREPEND features
# These tests first appeared in version 1.22.

use Text::Template;

die "This is the test program for Text::Template version 1.46
You are using version $Text::Template::VERSION instead.
That does not make sense.\n
Aborting"
  unless $Text::Template::VERSION == 1.46;

print "1..9\n";
my $n = 1;

@Emptyclass1::ISA = 'Text::Template';
@Emptyclass2::ISA = 'Text::Template';

my $tin = q{The value of $foo is: {$foo}};

Text::Template->always_prepend(q{$foo = "global"});

$tmpl1 = Text::Template->new(TYPE => 'STRING',
				SOURCE => $tin,		
			      );

$tmpl2 = Text::Template->new(TYPE => 'STRING',
			     SOURCE => $tin,		
			     PREPEND => q{$foo = "template"},
			     );

$tmpl1->compile;
$tmpl2->compile;

$t1 = $tmpl1->fill_in(PACKAGE => 'T1');
$t2 = $tmpl2->fill_in(PACKAGE => 'T2');
$t3 = $tmpl2->fill_in(PREPEND => q{$foo = "fillin"}, PACKAGE => 'T3');

($t1 eq 'The value of $foo is: global') or print "not ";
print "ok $n\n"; $n++;
($t2 eq 'The value of $foo is: template') or print "not ";
print "ok $n\n"; $n++;
($t3 eq 'The value of $foo is: fillin') or print "not ";
print "ok $n\n"; $n++;

Emptyclass1->always_prepend(q{$foo = 'Emptyclass global';});
$tmpl1 = Emptyclass1->new(TYPE => 'STRING',
				SOURCE => $tin,		
			      );

$tmpl2 = Emptyclass1->new(TYPE => 'STRING',
			     SOURCE => $tin,		
			     PREPEND => q{$foo = "template"},
			     );

$tmpl1->compile;
$tmpl2->compile;

$t1 = $tmpl1->fill_in(PACKAGE => 'T4');
$t2 = $tmpl2->fill_in(PACKAGE => 'T5');
$t3 = $tmpl2->fill_in(PREPEND => q{$foo = "fillin"}, PACKAGE => 'T6');

($t1 eq 'The value of $foo is: Emptyclass global') or print "not ";
print "ok $n\n"; $n++;
($t2 eq 'The value of $foo is: template') or print "not ";
print "ok $n\n"; $n++;
($t3 eq 'The value of $foo is: fillin') or print "not ";
print "ok $n\n"; $n++;

$tmpl1 = Emptyclass2->new(TYPE => 'STRING',
				SOURCE => $tin,		
			      );

$tmpl2 = Emptyclass2->new(TYPE => 'STRING',
			     SOURCE => $tin,		
			     PREPEND => q{$foo = "template"},
			     );

$tmpl1->compile;
$tmpl2->compile;

$t1 = $tmpl1->fill_in(PACKAGE => 'T4');
$t2 = $tmpl2->fill_in(PACKAGE => 'T5');
$t3 = $tmpl2->fill_in(PREPEND => q{$foo = "fillin"}, PACKAGE => 'T6');

($t1 eq 'The value of $foo is: global') or print "not ";
print "ok $n\n"; $n++;
($t2 eq 'The value of $foo is: template') or print "not ";
print "ok $n\n"; $n++;
($t3 eq 'The value of $foo is: fillin') or print "not ";
print "ok $n\n"; $n++;