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;
}