From: Nicholas Clark Date: Fri, 15 Apr 2011 13:16:22 +0000 (+0100) Subject: Eliminate needless test boilerplate, and duplicated effort. X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=6c3d85e783f17bed84a1c17f35042bfffbaad353;p=p5sagit%2FDevel-Size.git Eliminate needless test boilerplate, and duplicated effort. There's no need to change directory or duplicate the effects of -Mblib. Let use do the importing, rather than an explicit import call. use_ok() is arguably harmful - just let the use fail and take the entire test out cleanly, rather than carrying on and generating meaningless failures. No need to test ->can() and $VERSION in both - once is sufficient. --- diff --git a/t/basic.t b/t/basic.t index 1ccc78c..5a052af 100644 --- a/t/basic.t +++ b/t/basic.t @@ -1,25 +1,14 @@ #!/usr/bin/perl -w -use Test::More; +use Test::More tests => 14; use strict; - -BEGIN - { - chdir 't' if -d 't'; - plan tests => 15; - - use lib '../lib'; - use lib '../blib/arch'; - use_ok('Devel::Size'); - } +use Devel::Size qw(size total_size); can_ok ('Devel::Size', qw/ size total_size /); -Devel::Size->import( qw(size total_size) ); - die ("Uhoh, test uses an outdated version of Devel::Size") unless is ($Devel::Size::VERSION, '0.72_52', 'VERSION MATCHES'); diff --git a/t/recurse.t b/t/recurse.t index 01a9ba1..08524b1 100644 --- a/t/recurse.t +++ b/t/recurse.t @@ -6,28 +6,10 @@ # total_size([]) will NOT return the size of the ref + the array, it will only # return the size of the array alone! -use Test::More; +use Test::More tests => 3 + 4 *12; use strict; +use Devel::Size ':all'; -BEGIN - { - chdir 't' if -d 't'; - plan tests => 6 + 4 * 12; - - use lib '../lib'; - use lib '../blib/arch'; - use_ok('Devel::Size'); - } - -can_ok ('Devel::Size', qw/ - size - total_size - /); - -Devel::Size->import( qw(size total_size) ); - -die ("Uhoh, test uses an outdated version of Devel::Size") - unless is ($Devel::Size::VERSION, '0.72_52', 'VERSION MATCHES'); ############################################################################# # verify that pointer sizes in array slots are sensible: