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: 8891
Status: resolved
Priority: 0/
Queue: Test-Simple

People
Owner: Nobody in particular
Requestors: cpan [...] ali.as
Cc:
AdminCc:

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



Subject: Add the new_ok test
Normally, I wouldn't dream of suggesting adding a new testing function to the core Test::More distribution, but this one seems so obvious I am submitting it anyway. So many times I've had to do something like the following. my $Foo = Foo::Bar->new(...); isa_ok( $Foo, 'Foo::Bar' ); Now, given that we ALREADY type $Foo and Foo::Bar in the constructor, it would be very convenient to be able to just use an inline test, something like the following. my $Foo = new_ok( 'Foo::Bar', ... ); Note that it involves almost the same number of characters as just the new statement itself. It is concise and does exactly you would expect. Since it appear that the return values from the various test functions arn't used anyway, it would be very handy to have something like this. Implementation could be something as simple as sub new_ok { my ($class, @params) = @_; my $object = $class->new( @params ); isa_ok( $object, $class ); $object; }
[ADAMK - Wed Dec 15 01:19:06 2004]: Show quoted text
> my $Foo = new_ok( 'Foo::Bar', ... );
Not all constructors are called "new".
I am susceptible to bribes and surprisingly affordable.