3 # Tests for PREPEND features
4 # These tests first appeared in version 1.22.
8 die "This is the test program for Text::Template version 1.46
9 You are using version $Text::Template::VERSION instead.
10 That does not make sense.\n
12 unless $Text::Template::VERSION == 1.46;
17 @Emptyclass1::ISA = 'Text::Template';
18 @Emptyclass2::ISA = 'Text::Template';
20 my $tin = q{The value of $foo is: {$foo}};
22 Text::Template->always_prepend(q{$foo = "global"});
24 $tmpl1 = Text::Template->new(TYPE => 'STRING',
28 $tmpl2 = Text::Template->new(TYPE => 'STRING',
30 PREPEND => q{$foo = "template"},
36 $t1 = $tmpl1->fill_in(PACKAGE => 'T1');
37 $t2 = $tmpl2->fill_in(PACKAGE => 'T2');
38 $t3 = $tmpl2->fill_in(PREPEND => q{$foo = "fillin"}, PACKAGE => 'T3');
40 ($t1 eq 'The value of $foo is: global') or print "not ";
41 print "ok $n\n"; $n++;
42 ($t2 eq 'The value of $foo is: template') or print "not ";
43 print "ok $n\n"; $n++;
44 ($t3 eq 'The value of $foo is: fillin') or print "not ";
45 print "ok $n\n"; $n++;
47 Emptyclass1->always_prepend(q{$foo = 'Emptyclass global';});
48 $tmpl1 = Emptyclass1->new(TYPE => 'STRING',
52 $tmpl2 = Emptyclass1->new(TYPE => 'STRING',
54 PREPEND => q{$foo = "template"},
60 $t1 = $tmpl1->fill_in(PACKAGE => 'T4');
61 $t2 = $tmpl2->fill_in(PACKAGE => 'T5');
62 $t3 = $tmpl2->fill_in(PREPEND => q{$foo = "fillin"}, PACKAGE => 'T6');
64 ($t1 eq 'The value of $foo is: Emptyclass global') or print "not ";
65 print "ok $n\n"; $n++;
66 ($t2 eq 'The value of $foo is: template') or print "not ";
67 print "ok $n\n"; $n++;
68 ($t3 eq 'The value of $foo is: fillin') or print "not ";
69 print "ok $n\n"; $n++;
71 $tmpl1 = Emptyclass2->new(TYPE => 'STRING',
75 $tmpl2 = Emptyclass2->new(TYPE => 'STRING',
77 PREPEND => q{$foo = "template"},
83 $t1 = $tmpl1->fill_in(PACKAGE => 'T4');
84 $t2 = $tmpl2->fill_in(PACKAGE => 'T5');
85 $t3 = $tmpl2->fill_in(PREPEND => q{$foo = "fillin"}, PACKAGE => 'T6');
87 ($t1 eq 'The value of $foo is: global') or print "not ";
88 print "ok $n\n"; $n++;
89 ($t2 eq 'The value of $foo is: template') or print "not ";
90 print "ok $n\n"; $n++;
91 ($t3 eq 'The value of $foo is: fillin') or print "not ";
92 print "ok $n\n"; $n++;