chromatic wrote:
On Tue, 2005-03-08 at 17:31 -0500, David Golden wrote:Ick! No! My point was to keep it atomic -- by putting $Test->reason as its own separate call then you need a heuristic that says that any reasons apply to the previously seen test and so on. (And what do you do if you get two reason calls? Append? Replace? What about a reason call before any tests?) It's the diag problem all over again.
Yeah, it would be nice if we had a better way to handle this. Perhaps changing the idiom to:
$Test->ok( $dressed_up, 'How nice do you look?' ) || $Test->reason( 'Refusing to wear a tie and jacket' );
and encouraging Test::* module authors to adopt that type of error reporting will help.
You could go an OO route, setting up a results object then filing that as the details, e.g. (very off the cuff and not that well thought out):
my $r = $Test->new_result($expr,$name); # returns a new Test::Builder::Result object that stores pass/fail and a name
$r->reason($message) if $r->failed; # attach a reason
$Test->record($r); # Stick it in the details array (which now holds Result objects)
Regards,
David