1e1051a39Sopenharmony_ci#!perl 2e1051a39Sopenharmony_ci# 3e1051a39Sopenharmony_ci# Tests for PREPEND features 4e1051a39Sopenharmony_ci# These tests first appeared in version 1.22. 5e1051a39Sopenharmony_ci 6e1051a39Sopenharmony_ciuse strict; 7e1051a39Sopenharmony_ciuse warnings; 8e1051a39Sopenharmony_ciuse Test::More tests => 10; 9e1051a39Sopenharmony_ci 10e1051a39Sopenharmony_ciuse_ok 'Text::Template' or exit 1; 11e1051a39Sopenharmony_ci 12e1051a39Sopenharmony_ci@Emptyclass1::ISA = 'Text::Template'; 13e1051a39Sopenharmony_ci@Emptyclass2::ISA = 'Text::Template'; 14e1051a39Sopenharmony_ci 15e1051a39Sopenharmony_cimy $tin = q{The value of $foo is: {$foo}}; 16e1051a39Sopenharmony_ci 17e1051a39Sopenharmony_ciText::Template->always_prepend(q{$foo = "global"}); 18e1051a39Sopenharmony_ci 19e1051a39Sopenharmony_cimy $tmpl1 = Text::Template->new( 20e1051a39Sopenharmony_ci TYPE => 'STRING', 21e1051a39Sopenharmony_ci SOURCE => $tin); 22e1051a39Sopenharmony_ci 23e1051a39Sopenharmony_cimy $tmpl2 = Text::Template->new( 24e1051a39Sopenharmony_ci TYPE => 'STRING', 25e1051a39Sopenharmony_ci SOURCE => $tin, 26e1051a39Sopenharmony_ci PREPEND => q{$foo = "template"}); 27e1051a39Sopenharmony_ci 28e1051a39Sopenharmony_ci$tmpl1->compile; 29e1051a39Sopenharmony_ci$tmpl2->compile; 30e1051a39Sopenharmony_ci 31e1051a39Sopenharmony_cimy $t1 = $tmpl1->fill_in(PACKAGE => 'T1'); 32e1051a39Sopenharmony_cimy $t2 = $tmpl2->fill_in(PACKAGE => 'T2'); 33e1051a39Sopenharmony_cimy $t3 = $tmpl2->fill_in(PREPEND => q{$foo = "fillin"}, PACKAGE => 'T3'); 34e1051a39Sopenharmony_ci 35e1051a39Sopenharmony_ciis $t1, 'The value of $foo is: global'; 36e1051a39Sopenharmony_ciis $t2, 'The value of $foo is: template'; 37e1051a39Sopenharmony_ciis $t3, 'The value of $foo is: fillin'; 38e1051a39Sopenharmony_ci 39e1051a39Sopenharmony_ciEmptyclass1->always_prepend(q{$foo = 'Emptyclass global';}); 40e1051a39Sopenharmony_ci$tmpl1 = Emptyclass1->new( 41e1051a39Sopenharmony_ci TYPE => 'STRING', 42e1051a39Sopenharmony_ci SOURCE => $tin); 43e1051a39Sopenharmony_ci 44e1051a39Sopenharmony_ci$tmpl2 = Emptyclass1->new( 45e1051a39Sopenharmony_ci TYPE => 'STRING', 46e1051a39Sopenharmony_ci SOURCE => $tin, 47e1051a39Sopenharmony_ci PREPEND => q{$foo = "template"}); 48e1051a39Sopenharmony_ci 49e1051a39Sopenharmony_ci$tmpl1->compile; 50e1051a39Sopenharmony_ci$tmpl2->compile; 51e1051a39Sopenharmony_ci 52e1051a39Sopenharmony_ci$t1 = $tmpl1->fill_in(PACKAGE => 'T4'); 53e1051a39Sopenharmony_ci$t2 = $tmpl2->fill_in(PACKAGE => 'T5'); 54e1051a39Sopenharmony_ci$t3 = $tmpl2->fill_in(PREPEND => q{$foo = "fillin"}, PACKAGE => 'T6'); 55e1051a39Sopenharmony_ci 56e1051a39Sopenharmony_ciis $t1, 'The value of $foo is: Emptyclass global'; 57e1051a39Sopenharmony_ciis $t2, 'The value of $foo is: template'; 58e1051a39Sopenharmony_ciis $t3, 'The value of $foo is: fillin'; 59e1051a39Sopenharmony_ci 60e1051a39Sopenharmony_ci$tmpl1 = Emptyclass2->new( 61e1051a39Sopenharmony_ci TYPE => 'STRING', 62e1051a39Sopenharmony_ci SOURCE => $tin); 63e1051a39Sopenharmony_ci 64e1051a39Sopenharmony_ci$tmpl2 = Emptyclass2->new( 65e1051a39Sopenharmony_ci TYPE => 'STRING', 66e1051a39Sopenharmony_ci SOURCE => $tin, 67e1051a39Sopenharmony_ci PREPEND => q{$foo = "template"}); 68e1051a39Sopenharmony_ci 69e1051a39Sopenharmony_ci$tmpl1->compile; 70e1051a39Sopenharmony_ci$tmpl2->compile; 71e1051a39Sopenharmony_ci 72e1051a39Sopenharmony_ci$t1 = $tmpl1->fill_in(PACKAGE => 'T4'); 73e1051a39Sopenharmony_ci$t2 = $tmpl2->fill_in(PACKAGE => 'T5'); 74e1051a39Sopenharmony_ci$t3 = $tmpl2->fill_in(PREPEND => q{$foo = "fillin"}, PACKAGE => 'T6'); 75e1051a39Sopenharmony_ci 76e1051a39Sopenharmony_ciis $t1, 'The value of $foo is: global'; 77e1051a39Sopenharmony_ciis $t2, 'The value of $foo is: template'; 78e1051a39Sopenharmony_ciis $t3, 'The value of $foo is: fillin'; 79