An embarrassing non-bug

Ovid on 2005-01-27T03:19:11

chromatic submitted a nifty patch to collect better test result information in Test::Harness::Straps. I had some trouble with it so I played with it a bit. This little snippet worked:

# $result number is never zero if set, so this is OK
elsif (!$result{number} and my $extra = $self->_is_extra_line( $line )) {
                                       # But this isn't!
                                       # what $result{number}?
        my $test         = $totals->{details}[$result{number} - 1];
        $test->{extra} ||=  '';
        $test->{extra}  .= $extra;
        $type = 'other';
    }

It worked when it shouldn't have. You see, $result{number} was undefined. However, the $totals->{details} array was ordered and this snippet always affected the very last element of the array . . .

:)