File: 10-run.t

package info (click to toggle)
libdevel-nytprof-perl 5.06%2Bdfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 2,396 kB
  • ctags: 1,413
  • sloc: perl: 4,905; ansic: 101; sh: 54; makefile: 17
file content (57 lines) | stat: -rw-r--r-- 1,440 bytes parent folder | download | duplicates (4)
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
52
53
54
55
56
57
use Test::More;

use strict;
use lib qw(t/lib);
use NYTProfTest;

# test run_test_group() with extra_test_code and profile_this()

use Devel::NYTProf::Run qw(profile_this);

# tiny amount of source code to exercise RT#50851
my @src = (
    "\$a = 1;\n",
    "\$b = 2;\n",
);

run_test_group( {
    extra_options => {
    },
    extra_test_count => 17,
    extra_test_code  => sub {
        my ($profile, $env) = @_;

        $profile = profile_this(
            src_code => join('', @src),
            out_file => $env->{file},
            skip_sitecustomize => 1,
        );
        isa_ok $profile, 'Devel::NYTProf::Data';

        my ($fi, @others) = $profile->all_fileinfos;
        is @others, 0, 'should be one fileinfo';

        is $fi->fid, 1;
        is $fi->filename, '-'; # profile_this() does "| perl -"
        is $fi->abs_filename, '-';
        is $fi->filename_without_inc, '-';

        is $fi->eval_fi, undef;
        is $fi->eval_fid,  ''; # PL_sv_no
        is $fi->eval_line, ''; # PL_sv_no
        is_deeply $fi->evals_by_line, {};

        is $fi->profile, $profile;
        ok not $fi->is_eval;
        ok not $fi->is_fake;
        ok not $fi->is_pmc;

        my $line_time_data = $fi->line_time_data;
        is ref $line_time_data, 'ARRAY';

        is $fi->sum_of_stmts_count, 2;

        # should be tiny (will be 0 on systems without a highres clock)
        cmp_ok $fi->sum_of_stmts_time, '<', 10;
    },
});