Skip Menu |

Preferred bug tracker

Please visit the preferred bug tracker to report your issue.

This queue is for tickets about the Test-Simple CPAN distribution.

Report information
The Basics
Id: 27275
Status: rejected
Priority: 0/
Queue: Test-Simple

People
Owner: Nobody in particular
Requestors: dpisoni [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: Wishlist
Broken in: (no value)
Fixed in: (no value)



Subject: Expose Test::Builder->_is_diag() as public method
Hello, I recently wrote some code to depend on Test::Builder->_is_diag() to do its diagnostic output. I could have reimplemented it of course, but that would be silly, and of course if you change the format it will lead to inconsistency. I have no suggestion as to what this should be called if exposed, whether or not it should be exported/propogated. I just want it to be "stable" and consistent. (e.g., if you add treatment for another type other than 'eq', I'd like that "for free".) My use case: When I write data-driven tests, (e.g., verifying many fields of a "record") I don't want to have too many tests (read: "OKs") per iteration, preferring just to have one per record, so I do the verifications in an eval block without the test functions, having each "test" throw an exception if it fails. Then I simply check $@, if not set I issue a pass(), if set I issue a fail(). In the latter case, I follow up with a diag() with the detail, which comes in the exception. This is where I'm using _is_diag(). I encapsulated the failure part in a method (note, I am using Test::Class, so $self here is my Test::Class-derived object): sub fail_test_diag { my $self = shift; my($label,$err) = @_; # Since we're one step away from the actual failure, we need to bump this up local $Test::Builder::Level = $Test::Builder::Level + 1; fail( $label ); if ( ref $err and reftype $err eq 'ARRAY' ) { my($method, @diag) = @$err; diag( " method: $method" ); $self->is_diag( @diag ); } else { diag( $err ); } } sub is_diag { my $self = shift; # XXX Using unpublished interface here, may break later! $self->builder->_is_diag( @_ ); }
Unstructured diagnostic comments are going away in Test::Builder2 replaced with structured diagnostics. is() will still output comments, but it will be more a legacy thing. So there's not much point to exposing _is_diag() going forward.