Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 163 lines (142 sloc) 2.617 kb
36ff03e2 »
2000-12-15 *** empty log message ***
1 #============================================================= -*-perl-*-
2 #
3 # t/file.t
4 #
5 # Tests the File plugin.
6 #
7 # Written by Andy Wardley <abw@kfs.org>
8 #
9 # Copyright (C) 2000 Andy Wardley. All Rights Reserved.
10 #
11 # This is free software; you can redistribute it and/or modify it
12 # under the same terms as Perl itself.
13 #
14 # $Id$
15 #
16 #========================================================================
17
18 use strict;
19 use lib qw( ./lib ../lib );
20 use Template::Test;
21 use Template::Plugin::File;
22 $^W = 1;
23
4d622019 »
2001-04-06 2.02 release
24 if ($^O =~ /win/i) {
25 print "1..0\n";
26 exit(0);
27 }
28
29 #
36ff03e2 »
2000-12-15 *** empty log message ***
30 my $dir = -d 't' ? 't/test' : 'test';
31 my $file = "$dir/src/foo";
32 my @stat;
33 (@stat = stat $file)
34 || die "$file: $!\n";
35
36 my $vars = {
37 dir => $dir,
38 file => $file,
39 };
40 @$vars{ @Template::Plugin::File::STAT_KEYS } = @stat;
41
42 test_expect(\*DATA, undef, $vars);
43
44 __DATA__
45 -- test --
46 [% USE f = File('/foo/bar/baz.html', nostat=1) -%]
47 p: [% f.path %]
48 r: [% f.root %]
49 n: [% f.name %]
50 d: [% f.dir %]
51 e: [% f.ext %]
52 h: [% f.home %]
53 a: [% f.abs %]
54 -- expect --
55 p: /foo/bar/baz.html
56 r:
57 n: baz.html
58 d: /foo/bar
59 e: html
60 h: ../..
61 a: /foo/bar/baz.html
62
63 -- test --
64 [% USE f = File('foo/bar/baz.html', nostat=1) -%]
65 p: [% f.path %]
66 r: [% f.root %]
67 n: [% f.name %]
68 d: [% f.dir %]
69 e: [% f.ext %]
70 h: [% f.home %]
71 a: [% f.abs %]
72 -- expect --
73 p: foo/bar/baz.html
74 r:
75 n: baz.html
76 d: foo/bar
77 e: html
78 h: ../..
79 a: foo/bar/baz.html
80
81 -- test --
82 [% USE f = File('baz.html', nostat=1) -%]
83 p: [% f.path %]
84 r: [% f.root %]
85 n: [% f.name %]
86 d: [% f.dir %]
87 e: [% f.ext %]
88 h: [% f.home %]
89 a: [% f.abs %]
90 -- expect --
91 p: baz.html
92 r:
93 n: baz.html
94 d:
95 e: html
96 h:
97 a: baz.html
98
99
100 -- test --
101 [% USE f = File('bar/baz.html', root='/foo', nostat=1) -%]
102 p: [% f.path %]
103 r: [% f.root %]
104 n: [% f.name %]
105 d: [% f.dir %]
106 e: [% f.ext %]
107 h: [% f.home %]
108 a: [% f.abs %]
109 -- expect --
110 p: bar/baz.html
111 r: /foo
112 n: baz.html
113 d: bar
114 e: html
115 h: ..
116 a: /foo/bar/baz.html
117
118
119 -- test --
120 [% USE f = File('bar/baz.html', root='/foo', nostat=1) -%]
121 p: [% f.path %]
122 h: [% f.home %]
123 rel: [% f.rel('wiz/waz.html') %]
124 -- expect --
125 p: bar/baz.html
126 h: ..
127 rel: ../wiz/waz.html
128
129
130 -- test --
131 [% USE baz = File('foo/bar/baz.html', root='/tmp/tt2', nostat=1) -%]
132 [% USE waz = File('wiz/woz/waz.html', root='/tmp/tt2', nostat=1) -%]
133 [% baz.rel(waz) %]
134 -- expect --
135 ../../wiz/woz/waz.html
136
137
138 -- test --
139 [% USE f = File('foo/bar/baz.html', nostat=1) -%]
140 [[% f.atime %]]
141 -- expect --
142 []
143
144 -- test --
145 [% USE f = File(file) -%]
146 [% f.path %]
147 [% f.name %]
148 -- expect --
149 -- process --
150 [% dir %]/src/foo
151 foo
152
153 -- test --
154 [% USE f = File(file) -%]
155 [% f.path %]
156 [% f.mtime %]
157 -- expect --
158 -- process --
159 [% dir %]/src/foo
160 [% mtime %]
161
162
Something went wrong with that request. Please try again.