develooper Front page | perl.perl5.porters | Postings from November 2004

[perl #24853] [PATCH] Test::Builder's diag function is mistakely adding #'s (or not adding newlines)

Thread Next
From:
Steve Peters via RT
Date:
November 24, 2004 04:52
Subject:
[perl #24853] [PATCH] Test::Builder's diag function is mistakely adding #'s (or not adding newlines)
Message ID:
rt-3.0.11-24853-100933.19.0833532814783@perl.org
> [crazyinsomniac@yahoo.com - Thu Jan 08 05:18:53 2004]:
> 
> This is a bug report for perl from crazyinsomniac@yahoo.com,
> generated with the help of perlbug 1.33 running under perl v5.6.1.
> 
> 
> -----------------------------------------------------------------
> [Please enter your report here]
> 
>    $Test->diag(1,2,3,4);
> 
> yields "# 1# 2# 3# 4" which is not right.
> It seems like the intent was for each argument to be a line,
> so it should yield something like:
> 
>     # 1
>     # 2
>     # 3
>     # 4
> 
> The fix is to modify the foreach loop in sub diag like so:
> 
>     # Escape each line with a #.
>     foreach (@msgs) {
>         $_ = 'undef' unless defined;
>         s/^/# /gms;
>         $_.="\n" unless /\n/;
>     }
> 

This is still a problem under the current version of Test::Builder.

perl -e'use Test::Builder; print "$Test::Builder::VERSION\n"; my $Test =
Test::Builder->new; $Test->diag(1,2,3,4);'
0.20
# 1# 2# 3# 4

The change mentioned in the original ticket fixes the problem.  Below is
a patch for Test::Builder 0.20.

--- /usr/libdata/perl5/Test/Builder.pm  Tue Nov 23 03:50:54 2004
+++ /home/steve/Builder.pm      Wed Nov 24 06:46:14 2004
@@ -990,6 +990,7 @@
     foreach (@msgs) {
         $_ = 'undef' unless defined;
         s/^/# /gms;
+        $_.="\n" unless /\n/;
     }
 
     push @msgs, "\n" unless $msgs[-1] =~ /\n\Z/;



Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About