| 1 | use strictscip-perl cpan Devel-NYTProf 6.15 strict/; |
| 2 | use warningsscip-perl cpan Devel-NYTProf 6.15 warnings/; |
| 3 | use Carpscip-perl cpan Devel-NYTProf 6.15 Carp/; |
| 4 | use Configscip-perl cpan Devel-NYTProf 6.15 Config/ qw(%Config); |
| 5 | use Devel::NYTProf::Readerscip-perl cpan Devel-NYTProf 6.15 Devel/NYTProf/Reader/; |
| 6 | use Test::Morescip-perl cpan Devel-NYTProf 6.15 Test/More/; |
| 7 | use Devel::NYTProf::Constantsscip-perl cpan Devel-NYTProf 6.15 Devel/NYTProf/Constants/ qw( |
| 8 | NYTP_DEFAULT_COMPRESSION |
| 9 | NYTP_ZLIB_VERSION |
| 10 | ); |
| 11 | |
| 12 | planscip-perl cpan Devel-NYTProf 6.15 main/plan(). skip_all => "needs different profile data for testing on longdouble builds" |
| 13 | if (definedscip-perl cpan Devel-NYTProf 6.15 main/defined(). $Configscip-perl cpan Devel-NYTProf 6.15 main/`%Config`.{uselongdouble} and $Configscip-perl cpan Devel-NYTProf 6.15 main/`%Config`.{uselongdouble} eq 'define'); |
| 14 | |
| 15 | planscip-perl cpan Devel-NYTProf 6.15 main/plan(). skip_all => "needs different profile data for testing on quadmath builds" |
| 16 | if (definedscip-perl cpan Devel-NYTProf 6.15 main/defined(). $Configscip-perl cpan Devel-NYTProf 6.15 main/`%Config`.{usequadmath} and $Configscip-perl cpan Devel-NYTProf 6.15 main/`%Config`.{usequadmath} eq 'define'); |
| 17 | |
| 18 | my $file = "./t/nytprof_14-subinfo.out.txt"; |
| 19 | croakscip-perl cpan Devel-NYTProf 6.15 main/croak(). "No $file" unless -f $file; |
| 20 | |
| 21 | planscip-perl cpan Devel-NYTProf 6.15 main/plan(). skip_all => "$file doesn't work unless NYTP_ZLIB_VERSION is set" unless NYTP_ZLIB_VERSIONscip-perl cpan Devel-NYTProf 6.15 main/NYTP_ZLIB_VERSION().(); |
| 22 | |
| 23 | # General setup |
| 24 | |
| 25 | my $reporter = Devel::NYTProf::Reader->newscip-perl cpan Devel-NYTProf 6.15 Devel/NYTProf/Reader/new().($file, { quiet => 1 }); |
| 26 | okscip-perl cpan Devel-NYTProf 6.15 main/ok().(definedscip-perl cpan Devel-NYTProf 6.15 main/defined(). $reporter, "Devel::NYTProf::Reader->new returned defined entity"); |
| 27 | isa_okscip-perl cpan Devel-NYTProf 6.15 main/isa_ok().($reporter, 'Devel::NYTProf::Reader'); |
| 28 | |
| 29 | my $profile = $reporter->{profile}; |
| 30 | isa_okscip-perl cpan Devel-NYTProf 6.15 main/isa_ok().($profile, 'Devel::NYTProf::Data'); |
| 31 | |
| 32 | my ($pkgref, $subinfo_obj, @keys, $expect); |
| 33 | |
| 34 | $pkgref = $profile->package_subinfo_mapscip-perl cpan Devel-NYTProf 6.15 main/package_subinfo_map().(0,1); |
| 35 | isscip-perl cpan Devel-NYTProf 6.15 main/is().(refscip-perl cpan Devel-NYTProf 6.15 main/ref().($pkgref), 'HASH', |
| 36 | "Devel::NYTProf::Data->package_subinfo_map(0,1) returned hashref"); |
| 37 | @keys = keysscip-perl cpan Devel-NYTProf 6.15 main/keys(). %{$pkgref}; |
| 38 | isscip-perl cpan Devel-NYTProf 6.15 main/is().(@keys, 1, "1-element hash"); |
| 39 | $expect = 'main'; |
| 40 | isscip-perl cpan Devel-NYTProf 6.15 main/is().($keys[0], $expect, "Sole element is '$expect'"); |
| 41 | isa_okscip-perl cpan Devel-NYTProf 6.15 main/isa_ok().($pkgref->{$expect}{""}[0], 'Devel::NYTProf::SubInfo'); |
| 42 | $subinfo_obj = $pkgref->{$expect}{""}[0]; |
| 43 | isa_okscip-perl cpan Devel-NYTProf 6.15 main/isa_ok().($subinfo_obj, 'Devel::NYTProf::SubInfo'); |
| 44 | |
| 45 | ## Covered, but not explicitly: |
| 46 | ## recur_max_depth |
| 47 | ## recur_incl_time |
| 48 | ## cache |
| 49 | |
| 50 | $expect = 1; |
| 51 | isscip-perl cpan Devel-NYTProf 6.15 main/is().($subinfo_obj->fidscip-perl cpan Devel-NYTProf 6.15 main/fid()., $expect, "Got expected fid"); |
| 52 | |
| 53 | my ($fl, |
| 54 | $ll, $calls); |
| 55 | |
| 56 | $fl = $subinfo_obj->first_linescip-perl cpan Devel-NYTProf 6.15 main/first_line().; |
| 57 | okscip-perl cpan Devel-NYTProf 6.15 main/ok().(($fl =~ m/^\d+/ and $fl >= 0), "first_line() returned non-negative integer"); |
| 58 | $ll = $subinfo_obj->last_linescip-perl cpan Devel-NYTProf 6.15 main/last_line().; |
| 59 | okscip-perl cpan Devel-NYTProf 6.15 main/ok().(($ll =~ m/^\d+/ and $fl >= 0), "last_line() returned non-negative integer"); |
| 60 | $calls = $subinfo_obj->callsscip-perl cpan Devel-NYTProf 6.15 main/calls().; |
| 61 | okscip-perl cpan Devel-NYTProf 6.15 main/ok().(($calls =~ m/^\d+/ and $fl >= 0), "calls() returned non-negative integer"); |
| 62 | |
| 63 | my ($subname, $package, $without); |
| 64 | $subname = $subinfo_obj->subnamescip-perl cpan Devel-NYTProf 6.15 main/subname().; |
| 65 | ($package, $without) = splitscip-perl cpan Devel-NYTProf 6.15 main/split(). '::', $subname, 2; |
| 66 | isscip-perl cpan Devel-NYTProf 6.15 main/is().($package, 'main', "subname() returned expected package"); |
| 67 | isscip-perl cpan Devel-NYTProf 6.15 main/is().($subinfo_obj->subname_without_packagescip-perl cpan Devel-NYTProf 6.15 main/subname_without_package()., $without, |
| 68 | "subname_without_package() returned expected name"); |
| 69 | isscip-perl cpan Devel-NYTProf 6.15 main/is().($subinfo_obj->packagescip-perl cpan Devel-NYTProf 6.15 main/package()., $package, |
| 70 | "package() returned expected package"); |
| 71 | |
| 72 | $profile = $subinfo_obj->profilescip-perl cpan Devel-NYTProf 6.15 main/profile().; |
| 73 | isscip-perl cpan Devel-NYTProf 6.15 main/is().(refscip-perl cpan Devel-NYTProf 6.15 main/ref().($profile), 'Devel::NYTProf::Data', |
| 74 | "profile() returns Devel::NYTProf::Data object"); |
| 75 | |
| 76 | okscip-perl cpan Devel-NYTProf 6.15 main/ok().(definedscip-perl cpan Devel-NYTProf 6.15 main/defined().($subinfo_obj->incl_timescip-perl cpan Devel-NYTProf 6.15 main/incl_time().), "incl_time() returned defined value"); |
| 77 | okscip-perl cpan Devel-NYTProf 6.15 main/ok().(definedscip-perl cpan Devel-NYTProf 6.15 main/defined().($subinfo_obj->excl_timescip-perl cpan Devel-NYTProf 6.15 main/excl_time().), "excl_time() returned defined value"); |
| 78 | okscip-perl cpan Devel-NYTProf 6.15 main/ok().(definedscip-perl cpan Devel-NYTProf 6.15 main/defined().($subinfo_obj->recur_max_depthscip-perl cpan Devel-NYTProf 6.15 main/recur_max_depth().), "recur_max_depth() returned defined value"); |
| 79 | okscip-perl cpan Devel-NYTProf 6.15 main/ok().(definedscip-perl cpan Devel-NYTProf 6.15 main/defined().($subinfo_obj->recur_incl_timescip-perl cpan Devel-NYTProf 6.15 main/recur_incl_time().), "recur_incl_time() returned defined value"); |
| 80 | isscip-perl cpan Devel-NYTProf 6.15 main/is().(refscip-perl cpan Devel-NYTProf 6.15 main/ref().($subinfo_obj->cachescip-perl cpan Devel-NYTProf 6.15 main/cache().), 'HASH', "cache() returned hash ref"); |
| 81 | |
| 82 | my @caller_places = $subinfo_obj->caller_placesscip-perl cpan Devel-NYTProf 6.15 main/caller_places().; |
| 83 | for my $c (@caller_places) { |
| 84 | isscip-perl cpan Devel-NYTProf 6.15 main/is().(refscip-perl cpan Devel-NYTProf 6.15 main/ref().($c), 'ARRAY', |
| 85 | "each element of any returned by caller_places() is an array ref"); |
| 86 | } |
| 87 | isscip-perl cpan Devel-NYTProf 6.15 main/is().($subinfo_obj->caller_countscip-perl cpan Devel-NYTProf 6.15 main/caller_count()., scalarscip-perl cpan Devel-NYTProf 6.15 main/scalar().(@caller_places), |
| 88 | "caller_count() returned expected count"); |
| 89 | |
| 90 | my $fileinfo = $subinfo_obj->fileinfoscip-perl cpan Devel-NYTProf 6.15 main/fileinfo().; |
| 91 | isa_okscip-perl cpan Devel-NYTProf 6.15 main/isa_ok().($fileinfo, 'Devel::NYTProf::FileInfo'); |
| 92 | |
| 93 | done_testingscip-perl cpan Devel-NYTProf 6.15 main/done_testing().(); |