[Templates-cvs] cvs commit: TT3/t utils.t
cvs@template-toolkit.org
cvs@template-toolkit.org
Tue, 23 Mar 2004 11:05:50 +0000
cvs 04/03/23 11:05:50
Modified: t utils.t
Log:
* updated utils for Template::Utils module
Revision Changes Path
1.2 +32 -9 TT3/t/utils.t
Index: utils.t
===================================================================
RCS file: /template-toolkit/TT3/t/utils.t,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- utils.t 2003/12/04 12:21:44 1.1
+++ utils.t 2004/03/23 11:05:50 1.2
@@ -2,14 +2,14 @@
#
# t/utils.t
#
-# Test the Template::TT3::Utils.pm module.
+# Test the Template::Utils.pm module.
#
# Written by Andy Wardley <abw@wardley.org>
#
# This is free software; you can redistribute it and/or modify it
# under the same terms as Perl itself.
#
-# $Id: utils.t,v 1.1 2003/12/04 12:21:44 abw Exp $
+# $Id: utils.t,v 1.2 2004/03/23 11:05:50 abw Exp $
#
#========================================================================
@@ -17,14 +17,14 @@
use warnings;
use lib qw( ./lib ../lib );
-use Template::TT3::Utils;
-use Test::More tests => 11;
+use Template::Utils;
+use Test::More tests => 12;
use File::Spec;
my $dir = -d 'testdata' ? 'testdata' : 't/testdata';
my $foo = File::Spec->catfile($dir, 'foo');
my $bar = File::Spec->catfile($dir, 'bar');
-my $pkg = 'Template::TT3::Utils';
+my $pkg = 'Template::Utils';
my $obj = $pkg->new();
@@ -51,24 +51,47 @@
my $text = $pkg->load_file($foo) || die $pkg->error();
ok( $text, 'class loaded foo' );
-ok( $text =~ /^This is the foo file.\s+Hello World!/,
+ok( $$text =~ /^This is the foo file.\s+Hello World!/,
'foo contents are correct' );
$text = 'I wrote this file';
-ok( $pkg->save_file($bar, $text), 'class wrote text to bar' );
+ok( $pkg->save_file($bar, $text) || die($pkg->error()),
+ 'class wrote text to bar' );
$text = $obj->load_file($bar) || die $obj->error();
ok( $text, 'object loaded bar' );
-is( $text, 'I wrote this file', 'object bar contents are correct' );
+is( $$text, 'I wrote this file', 'object bar contents are correct' );
+
+#------------------------------------------------------------------------
+# save_file()
+#------------------------------------------------------------------------
+
$text = 'I also wrote this file';
ok( $obj->save_file($bar, \$text), 'object wrote text to bar' );
$text = $pkg->load_file($bar) || die $pkg->error();
ok( $text, 'class loaded bar' );
-is( $text, 'I also wrote this file', 'class bar contents are correct' );
+is( $$text, 'I also wrote this file', 'class bar contents are correct' );
+
+
+#------------------------------------------------------------------------
+# file)path
+#------------------------------------------------------------------------
+
+$text = $pkg->file_path('/foo/', '/bar/baz/', '/wam.txt');
+is( $text, '/foo/bar/baz/wam.txt', 'file_path() correct' );
__END__
+
+# Local Variables:
+# mode: perl
+# perl-indent-level: 4
+# indent-tabs-mode: nil
+# End:
+#
+# vim: expandtab shiftwidth=4:
+