1e1051a39Sopenharmony_ci#!perl 2e1051a39Sopenharmony_ci# 3e1051a39Sopenharmony_ci# test apparatus for Text::Template module 4e1051a39Sopenharmony_ci# still incomplete. 5e1051a39Sopenharmony_ci# 6e1051a39Sopenharmony_ci 7e1051a39Sopenharmony_ciuse strict; 8e1051a39Sopenharmony_ciuse warnings; 9e1051a39Sopenharmony_ciuse Test::More tests => 4; 10e1051a39Sopenharmony_ci 11e1051a39Sopenharmony_ciuse_ok 'Text::Template' or exit 1; 12e1051a39Sopenharmony_ci 13e1051a39Sopenharmony_cimy $templateIN = q{ 14e1051a39Sopenharmony_ciThis line should have a 3: {1+2} 15e1051a39Sopenharmony_ci 16e1051a39Sopenharmony_ciThis line should have several numbers: 17e1051a39Sopenharmony_ci{ $t = ''; foreach $n (1 .. 20) { $t .= $n . ' ' } $t } 18e1051a39Sopenharmony_ci}; 19e1051a39Sopenharmony_ci 20e1051a39Sopenharmony_cimy $templateOUT = q{ 21e1051a39Sopenharmony_ciThis line should have a 3: { $OUT = 1+2 } 22e1051a39Sopenharmony_ci 23e1051a39Sopenharmony_ciThis line should have several numbers: 24e1051a39Sopenharmony_ci{ foreach $n (1 .. 20) { $OUT .= $n . ' ' } } 25e1051a39Sopenharmony_ci}; 26e1051a39Sopenharmony_ci 27e1051a39Sopenharmony_ci# Build templates from string 28e1051a39Sopenharmony_cimy $template = Text::Template->new('type' => 'STRING', 'source' => $templateIN); 29e1051a39Sopenharmony_ciisa_ok $template, 'Text::Template'; 30e1051a39Sopenharmony_ci 31e1051a39Sopenharmony_ci$templateOUT = Text::Template->new('type' => 'STRING', 'source' => $templateOUT); 32e1051a39Sopenharmony_ciisa_ok $templateOUT, 'Text::Template'; 33e1051a39Sopenharmony_ci 34e1051a39Sopenharmony_ci# Fill in templates 35e1051a39Sopenharmony_cimy $text = $template->fill_in(); 36e1051a39Sopenharmony_cimy $textOUT = $templateOUT->fill_in(); 37e1051a39Sopenharmony_ci 38e1051a39Sopenharmony_ci# (1) They should be the same 39e1051a39Sopenharmony_ciis $text, $textOUT; 40e1051a39Sopenharmony_ci 41e1051a39Sopenharmony_ci# Missing: Test this feature in Safe compartments; 42e1051a39Sopenharmony_ci# it's a totally different code path. 43e1051a39Sopenharmony_ci# Decision: Put that into safe.t, because that file should 44e1051a39Sopenharmony_ci# be skipped when Safe.pm is unavailable. 45e1051a39Sopenharmony_ci 46e1051a39Sopenharmony_ciexit; 47