I've been playing with Devel::Cover recently and while I don't
completely trust it, the information it does give is terribly useful
and very comforting. Basically, the following command:
$ perl -e 'foreach (<t/*.t>) { system(qq{perl -Ilib -Iblib/arch \
-MDevel::Cover $_})}'
... runs all the tests in turn (ignore the text flying by, the last
one is the important one) and sees how much the tests cover the
code. This is a tricky subject to measure (read the docs!) but
basically it shows us that the tests are testing most of the code. The
attached patches to the tests increase the coverage by a little.
Leon
ps patches are to version 2.04
--
Leon Brocard.............................http://www.astray.com/
Iterative Software...........http://www.iterative-software.com/
... I have seen the evidence. I want DIFFERENT evidence!
--- exception.t.orig Wed Aug 22 15:23:29 2001
+++ exception.t Wed Aug 22 15:25:59 2001
@@ -45,3 +45,9 @@
my @handlers = ('something', 'e2', 'e1.type');
ok( $e1->select_handler(@handlers) eq 'e1.type' );
ok( $e2->select_handler(@handlers) eq 'e2' );
+
+my $e3 = Template::Exception->new('e3.type', 'e3.info', undef);
+ok( $e3 );
+ok( $e3->text() eq '');
+ok( $e3->as_string() eq 'e3.type error - e3.info' );
+
--- file.t.orig Wed Aug 22 15:32:10 2001
+++ file.t Wed Aug 22 15:36:40 2001
@@ -168,4 +168,14 @@
[% dir %]/src/foo
[% mtime %]
+-- test --
+[% TRY -%]
+[% USE f = File('') -%]
+n: [% f.name %]
+[% CATCH -%]
+Drat, there was a [% error.type %] error.
+[% END %]
+-- expect --
+Drat, there was a File error.
+
--- html.t.orig Wed Aug 22 15:40:34 2001
+++ html.t Wed Aug 22 16:04:12 2001
@@ -57,3 +57,21 @@
[%- END %]
-- expect --
< & >
+
+-- test --
+[% USE HTML -%]
+[% HTML.escape("if (a < b && c > d) ...") %]
+-- expect --
+if (a < b && c > d) ...
+
+-- test --
+[% USE HTML -%]
+[% HTML.element(table => { border => 1, cellpadding => 2 }) %]
+-- expect --
+<table cellpadding="2" border="1">
+
+-- test --
+[% USE HTML -%]
+[% HTML.attributes(border => 1, cellpadding => 2) %]
+-- expect --
+cellpadding="2" border="1"
--- template.t.orig Wed Aug 22 15:01:37 2001
+++ template.t Wed Aug 22 16:04:46 2001
@@ -40,4 +40,28 @@
ok( $error->type() eq 'file' );
ok( $error->info() eq 'this_file_does_not_exist: not found' );
+sub myout {
+ my $output = shift;
+ ok($output)
+}
+ok($tt->process('header', undef, \&myout));
+
+my $out = Myout->new();
+
+ok($tt->process('header', undef, $out));
+
+package Myout;
+use Template::Test;
+
+sub new {
+ my $proto = shift;
+ my $class = ref($proto) || $proto;
+ my $self = {};
+ bless($self, $class);
+ return $self;
+}
+sub print {
+ my $output = shift;
+ ok($output);
+}