• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#!perl
2#
3# test apparatus for Text::Template module
4# still incomplete.
5#
6
7use Text::Template;
8
9die "This is the test program for Text::Template version 1.46
10You are using version $Text::Template::VERSION instead.
11That does not make sense.\n
12Aborting"
13  unless $Text::Template::VERSION == 1.46;
14
15print "1..1\n";
16
17$n=1;
18
19$template = q{
20This line should have a 3: {1+2}
21
22This line should have several numbers:
23{ $t = ''; foreach $n (1 .. 20) { $t .= $n . ' ' } $t }
24};
25
26$templateOUT = q{
27This line should have a 3: { $OUT = 1+2 }
28
29This line should have several numbers:
30{ foreach $n (1 .. 20) { $OUT .= $n . ' ' } }
31};
32
33# Build templates from string
34$template = new Text::Template ('type' => 'STRING', 'source' => $template)
35  or die;
36$templateOUT = new Text::Template ('type' => 'STRING', 'source' => $templateOUT)
37  or die;
38
39# Fill in templates
40$text = $template->fill_in()
41  or die;
42$textOUT = $templateOUT->fill_in()
43  or die;
44
45# (1) They should be the same
46print +($text eq $textOUT ? '' : 'not '), "ok $n\n";
47$n++;
48
49# Missing:  Test this feature in Safe compartments;
50# it's a totally different code path.
51# Decision: Put that into safe.t, because that file should
52# be skipped when Safe.pm is unavailable.
53
54
55exit;
56
57