Revision: 929 Author: tim.bunce Date: Fri Dec 4 12:40:49 2009 Log: Fixed file_line_range_of_sub to handle known subs with unknown file details, like UNIVERSAL::VERSION
http://code.google.com/p/perl-devel-nytprof/source/detail?r=929 Added: /trunk/t/44-model.t Modified: /trunk/MANIFEST /trunk/lib/Devel/NYTProf/Data.pm ======================================= --- /dev/null +++ /trunk/t/44-model.t Fri Dec 4 12:40:49 2009 @@ -0,0 +1,33 @@ +# Tests assorted data model methods + +use strict; +use Test::More; + +use lib qw(t/lib); +use NYTProfTest; +use Data::Dumper; + +use Devel::NYTProf::Run qw(profile_this); + +run_test_group( { + extra_options => { start => 'begin' }, + extra_test_count => 2, + extra_test_code => sub { + my ($profile, $env) = @_; + + my $src_code = q{ + use strict 0.01; + }; + $profile = profile_this( + src_code => $src_code, + out_file => $env->{file}, + ); + isa_ok $profile, 'Devel::NYTProf::Data'; + + my $subs = $profile->subname_subinfo_map; + my @tmp; + @tmp = $profile->file_line_range_of_sub("UNIVERSAL::VERSION"); + is @tmp, 0, 'UNIVERSAL::VERSION should have no known file or line range'; + + }, +}); ======================================= --- /trunk/MANIFEST Sun Nov 22 14:02:17 2009 +++ /trunk/MANIFEST Fri Dec 4 12:40:49 2009 @@ -54,6 +54,7 @@ t/31-env.t t/40-savesrc.t t/42-global.t +t/44-model.t t/50-errno.t t/60-forkdepth.t t/80-version.t ======================================= --- /trunk/lib/Devel/NYTProf/Data.pm Sun Nov 22 14:02:17 2009 +++ /trunk/lib/Devel/NYTProf/Data.pm Fri Dec 4 12:40:49 2009 @@ -681,7 +681,10 @@ or return; # no such sub my ($fid, $first, $last) = @$sub_subinfo; - my $fileinfo = $fid && $self->{fid_fileinfo}->[$fid]; + return if not $fid; # sub has no known file + + my $fileinfo = $fid && $self->{fid_fileinfo}->[$fid] + or die "No fid_fileinfo for sub $sub fid '$fid'\n"; while ($fileinfo->eval_fid) { # eg string eval -- You've received this message because you are subscribed to the Devel::NYTProf Development User group. Group hosted at: http://groups.google.com/group/develnytprof-dev Project hosted at: http://perl-devel-nytprof.googlecode.com CPAN distribution: http://search.cpan.org/dist/Devel-NYTProf To post, email: [email protected] To unsubscribe, email: [email protected]
