Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 73 lines (58 sloc) 1.613 kb
3ebfa07 @abw Initial revision
authored
1 #============================================================= -*-perl-*-
2 #
3 # t/datafile.t
4 #
5 # Template script testing datafile plugin.
6 #
82cbea8 @abw version 2.00
authored
7 # Written by Andy Wardley <abw@kfs.org>
3ebfa07 @abw Initial revision
authored
8 #
3e45060 @abw *** empty log message ***
authored
9 # Copyright (C) 1996-2000 Andy Wardley. All Rights Reserved.
10 # Copyright (C) 1998-2000 Canon Research Centre Europe Ltd.
3ebfa07 @abw Initial revision
authored
11 #
12 # This is free software; you can redistribute it and/or modify it
13 # under the same terms as Perl itself.
14 #
15 # $Id$
16 #
17 #========================================================================
18
19 use strict;
20 use lib qw( ../lib );
21 use Template qw( :status );
22 use Template::Test;
23 $^W = 1;
24
25 $Template::Test::DEBUG = 0;
26
27 my $base = -d 't' ? 't/test/lib' : 'test/lib';
28 my $params = {
29 datafile => [ "$base/udata1", "$base/udata2" ],
30 };
31
32 test_expect(\*DATA, { INTERPOLATE => 1, POST_CHOMP => 1 }, $params);
33
34
35
36 #------------------------------------------------------------------------
37 # test input
38 #------------------------------------------------------------------------
39
40 __DATA__
41 [% USE userlist = datafile(datafile.0) %]
42 Users:
43 [% FOREACH user = userlist %]
44 * $user.id: $user.name
45 [% END %]
46
47 -- expect --
48 Users:
49 * way: Wendy Yardley
50 * mop: Marty Proton
51 * nellb: Nell Browser
52
53 -- test --
54 [% USE userlist = datafile(datafile.1, delim = '|') %]
55 Users:
56 [% FOREACH user = userlist %]
9de6bd5 @abw *** empty log message ***
authored
57 * $user.id: $user.name <$user.email>
3ebfa07 @abw Initial revision
authored
58 [% END %]
59
60 -- expect --
61 Users:
9de6bd5 @abw *** empty log message ***
authored
62 * way: Wendy Yardley <way@cre.canon.co.uk>
63 * mop: Marty Proton <mop@cre.canon.co.uk>
64 * nellb: Nell Browser <nellb@cre.canon.co.uk>
3ebfa07 @abw Initial revision
authored
65
6ddeb78 @abw added leak.t
authored
66 -- test --
67 [% USE userlist = datafile(datafile.1, delim = '|') -%]
68 size: [% userlist.size %]
69 -- expect --
70 size: 3
3ebfa07 @abw Initial revision
authored
71
72
Something went wrong with that request. Please try again.