X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=t%2Frecurse.t;h=08524b14a795fe364942ef6daccd937ca8d0e2b4;hb=5f04c81daf0e38670b8dac45bd369bc508da50b6;hp=2bf7a8d6dc4100d82a2ebfc77d75f36d592f42e9;hpb=b76217297a5f92982c29177d97eb655b52d164eb;p=p5sagit%2FDevel-Size.git diff --git a/t/recurse.t b/t/recurse.t index 2bf7a8d..08524b1 100644 --- a/t/recurse.t +++ b/t/recurse.t @@ -6,30 +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; - -my $tests; +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.71', 'VERSION MATCHES'); ############################################################################# # verify that pointer sizes in array slots are sensible: @@ -50,9 +30,9 @@ $ptr_size /= 4; my $hash = {}; $hash->{a} = 1; -is (total_size($hash), - total_size( { a => undef } ) + total_size(1) - total_size(undef), - 'assert hash and hash key size'); +is (total_size($hash), + total_size( { a => undef } ) + total_size(1) - total_size(undef), + 'assert hash and hash key size'); ############################################################################# # #24846 (Does not correctly recurse into references in a PVNV-type scalar) @@ -112,8 +92,8 @@ for my $size (2, 3, 7, 100) # Get the size of the PVNV and the contained array my $element_size = total_size(\$hash->{a}); - ok ($element_size < total_size($hash), "element < hash with one element"); - ok ($element_size > total_size(\[]), "PVNV + [] > [] alone"); + cmp_ok($element_size, '<', total_size($hash), "element < hash with one element"); + cmp_ok($element_size, '>', total_size(\[]), "PVNV + [] > [] alone"); # Dereferencing the PVNV (the argument to total_size) leaves us with # just the array, and this should be equal to a dereferenced array: @@ -138,7 +118,7 @@ for my $size (2, 3, 7, 100) # is a PVNV, so they shouldn't be the same: isnt (total_size(\[0..$size]), total_size( \$hash->{a} ), "[0..size] vs PVNV"); # and the plain ref should be smaller - ok (total_size(\[0..$size]) < total_size( \$hash->{a} ), "[0..size] vs. PVNV"); + cmp_ok(total_size(\[0..$size]), '<', total_size( \$hash->{a} ), "[0..size] vs. PVNV"); $full_hash = total_size($hash); $element_size = total_size(\$hash->{a});