Commit | Line | Data |
57fcdb5b |
1 | #!/usr/bin/perl -w |
2 | |
3 | use strict; |
219b7d34 |
4 | use Test::More tests => 12; |
d3b8a135 |
5 | use Devel::Memory ':all'; |
57fcdb5b |
6 | |
7 | sub zwapp; |
8 | sub swoosh($$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$); |
9 | sub crunch { |
10 | } |
11 | |
12 | my $whack_size = total_size(\&whack); |
13 | my $zwapp_size = total_size(\&zwapp); |
14 | my $swoosh_size = total_size(\&swoosh); |
15 | my $crunch_size = total_size(\&crunch); |
16 | |
17 | cmp_ok($whack_size, '>', 0, 'CV generated at runtime has a size'); |
18 | cmp_ok($zwapp_size, '>', $whack_size, |
19 | 'CV stubbed at compiletime is larger (CvOUTSIDE is set and followed)'); |
20 | cmp_ok(length prototype \&swoosh, '>', 0, 'prototype has a length'); |
21 | cmp_ok($swoosh_size, '>', $zwapp_size + length prototype \&swoosh, |
22 | 'prototypes add to the size'); |
23 | cmp_ok($crunch_size, '>', $zwapp_size, 'sub bodies add to the size'); |
24 | |
25 | my $anon_proto = sub ($$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$) {}; |
26 | my $anon_size = total_size(sub {}); |
27 | my $anon_proto_size = total_size($anon_proto); |
28 | cmp_ok($anon_size, '>', 0, 'anonymous subroutines have a size'); |
29 | cmp_ok(length prototype $anon_proto, '>', 0, 'prototype has a length'); |
30 | cmp_ok($anon_proto_size, '>', $anon_size + length prototype $anon_proto, |
31 | 'prototypes add to the size'); |
574d9fd9 |
32 | |
4c229154 |
33 | SKIP: { |
574d9fd9 |
34 | use vars '@b'; |
35 | my $aelemfast_lex = total_size(sub {my @a; $a[0]}); |
36 | my $aelemfast = total_size(sub {my @a; $b[0]}); |
37 | |
4c229154 |
38 | # This one is sane even before Dave's lexical aelemfast changes: |
574d9fd9 |
39 | cmp_ok($aelemfast_lex, '>', $anon_size, |
40 | 'aelemfast for a lexical is handled correctly'); |
4c229154 |
41 | skip('alemfast was extended to lexicals after this perl was released', 1) |
42 | if $] < 5.008004; |
574d9fd9 |
43 | cmp_ok($aelemfast, '>', $aelemfast_lex, |
44 | 'aelemfast for a package variable is larger'); |
45 | } |
219b7d34 |
46 | |
47 | my $short_pvop = total_size(sub {goto GLIT}); |
48 | my $long_pvop = total_size(sub {goto KREEK_KREEK_CLANK_CLANK}); |
49 | cmp_ok($short_pvop, '>', $anon_size, 'OPc_PVOP can be measured'); |
50 | is($long_pvop, $short_pvop + 19, 'the only size difference is the label length'); |