1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51
|
#!/usr/bin/perl
use v5.14;
use warnings;
use Test2::V0;
use Devel::MAT::Dumper;
use Devel::MAT;
my $DUMPFILE = __FILE__ =~ s/\.t/\.pmat/r;
our $EMPTY_SVIV = 123;
our @EMPTY_AV = ();
our @ARRAY = ( 123, 45, [ 6, 7 ] );
Devel::MAT::Dumper::dump( $DUMPFILE );
END { unlink $DUMPFILE; }
my $pmat = Devel::MAT->load( $DUMPFILE );
ok ( scalar( grep { $_ eq "Sizes" } $pmat->available_tools ), 'Sizes tool is available' );
$pmat->load_tool( "Sizes" );
my $sviv_size = $pmat->find_symbol( '$EMPTY_SVIV' )->size;
my $av_size = $pmat->find_symbol( '@EMPTY_AV' )->size;
my $av = $pmat->find_symbol( '@ARRAY' );
my $av2 = $av->elem(2)->rv;
# Structure
{
is( scalar $av->structure_set, 4, '$av->structure_set' );
cmp_ok( $av->size, '>', $av_size, '$av->size > $av_size' );
is( $av->structure_size,
$av->size + 3*$sviv_size,
'$av->structure_size' );
}
# Owned
{
is( scalar $av->owned_set, 7, '$av->owned_set' );
is( $av->owned_size,
$av->size + 3*$sviv_size + $av2->size + 2*$sviv_size,
'$av->owned_size' );
}
done_testing;
|