Adding Text::Diff into Template::Test (if only available) will allows
you to generate more *readable* diff for $expect and $output.
The idea comes from Test::Differences on CPAN.
Index: lib/Template/Test.pm
===================================================================
RCS file: /template-toolkit/Template2/lib/Template/Test.pm,v
retrieving revision 2.58
diff -u -r2.58 Test.pm
--- lib/Template/Test.pm 2002/08/15 16:41:31 2.58
+++ lib/Template/Test.pm 2002/08/27 06:47:31
@@ -341,21 +341,29 @@
if (! $match || $DEBUG) {
print "MATCH FAILED\n"
unless $match;
-
- my ($copyi, $copye, $copyo) = ($input, $expect, $output);
- unless ($PRESERVE) {
- foreach ($copyi, $copye, $copyo) {
- s/\n/\\n/g;
- }
- }
- printf(" input: [%s]\nexpect: [%s]\noutput: [%s]\n",
- $copyi, $copye, $copyo);
+ diff_out($input, $expect, $output);
}
ok($match, $match ? "$name matched expected" : "$name did not match expected");
};
}
+sub diff_out {
+ my ($copyi, $copye, $copyo) = @_;
+ eval { require Text::Diff };
+ if ($@) {
+ unless ($PRESERVE) {
+ foreach ($copyi, $copye, $copyo) {
+ s/\n/\\n/g;
+ }
+ }
+ printf(" input: [%s]\nexpect: [%s]\noutput: [%s]\n",
+ $copyi, $copye, $copyo);
+ } else {
+ print Text::Diff::diff(\$copye, \$copyo), "\n";
+ }
+}
+
#------------------------------------------------------------------------
# callsign()
#
@@ -694,4 +702,4 @@
=head1 SEE ALSO
-L<Template|Template>
\ No newline at end of file
+L<Template|Template>
_______________________________________________
templates mailing list
[EMAIL PROTECTED]
http://www.template-toolkit.org/mailman/listinfo/templates