This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
d9d9e7b41a3b4506a3eccdf44a096e728ec9b2a5
[perl5.git] / ext / B / t / b.t
1 #!./perl
2
3 BEGIN {
4     unshift @INC, 't';
5     require Config;
6     if (($Config::Config{'extensions'} !~ /\bB\b/) ){
7         print "1..0 # Skip -- Perl configured without B module\n";
8         exit 0;
9     }
10 }
11
12 $|  = 1;
13 use warnings;
14 use strict;
15 BEGIN  {
16     eval { require threads; threads->import; }
17 }
18 use Test::Stream 'enable_fork';
19 use Test::More;
20
21 BEGIN { use_ok( 'B' ); }
22
23
24 package Testing::Symtable;
25 use vars qw($This @That %wibble $moo %moo);
26 my $not_a_sym = 'moo';
27
28 sub moo { 42 }
29 sub car { 23 }
30
31
32 package Testing::Symtable::Foo;
33 sub yarrow { "Hock" }
34
35 package Testing::Symtable::Bar;
36 sub hock { "yarrow" }
37
38 package main;
39 use vars qw(%Subs);
40 local %Subs = ();
41 B::walksymtable(\%Testing::Symtable::, 'find_syms', sub { $_[0] =~ /Foo/ },
42                 'Testing::Symtable::');
43
44 sub B::GV::find_syms {
45     my($symbol) = @_;
46
47     $main::Subs{$symbol->STASH->NAME . '::' . $symbol->NAME}++;
48 }
49
50 my @syms = map { 'Testing::Symtable::'.$_ } qw(This That wibble moo car
51                                                BEGIN);
52 push @syms, "Testing::Symtable::Foo::yarrow";
53
54 # Make sure we hit all the expected symbols.
55 ok( join('', sort @syms) eq join('', sort keys %Subs), 'all symbols found' );
56
57 # Make sure we only hit them each once.
58 ok( (!grep $_ != 1, values %Subs), '...and found once' );
59
60 # Tests for MAGIC / MOREMAGIC
61 ok( B::svref_2object(\$.)->MAGIC->TYPE eq "\0", '$. has \0 magic' );
62 {
63     my $e = '';
64     local $SIG{__DIE__} = sub { $e = $_[0] };
65     # Used to dump core, bug #16828
66     eval { B::svref_2object(\$.)->MAGIC->MOREMAGIC->TYPE; };
67     like( $e, qr/Can't call method "TYPE" on an undefined value/, 
68         '$. has no more magic' );
69 }
70
71 {
72     my $pie = 'Good';
73     # This needs to be a package variable, as vars in the pad have some flags.
74     my $r = B::svref_2object(\$::data2);
75     is($r->FLAGS(), 0, "uninitialised package variable has flags of 0");
76     is($r->SvTYPE(), 0, "uninitialised package variable has type 0");
77     is($r->POK(), 0, "POK false");
78     is($r->ROK(), 0, "ROK false");
79     is($r->MAGICAL(), 0, "MAGICAL false");
80     $::data2 = $pie;
81     isnt($r->FLAGS(), 0, "initialised package variable has nonzero flags");
82     isnt($r->SvTYPE(), 0, "initialised package variable has nonzero type");
83     isnt($r->POK(), 0, "POK true");
84     is($r->ROK(), 0, "ROK false");
85     is($r->MAGICAL(), 0, "MAGICAL false");
86
87     $::data2 = substr $pie, 0, 1;
88     isnt($r->FLAGS(), 0, "initialised package variable has nonzero flags");
89     isnt($r->SvTYPE(), 0, "initialised package variable has nonzero type");
90     isnt($r->POK(), 0, "POK true");
91     is($r->ROK(), 0, "ROK false");
92     is($r->MAGICAL(), 0, "MAGICAL true");
93
94     $::data2 = \$pie;
95     isnt($r->FLAGS(), 0, "initialised package variable has nonzero flags");
96     isnt($r->SvTYPE(), 0, "initialised package variable has nonzero type");
97     is($r->POK(), 0, "POK false");
98     isnt($r->ROK(), 0, "ROK true");
99     is($r->MAGICAL(), 0, "MAGICAL false");
100
101     is($r->REFCNT(), 1, "Reference count is 1");
102     {
103         my $ref = \$::data2;
104         is($r->REFCNT(), 2, "Second reference");
105     }
106     is($r->REFCNT(), 1, "Reference count is 1");
107
108 }
109
110 my $r = qr/foo/;
111 my $obj = B::svref_2object($r);
112 my $regexp =  ($] < 5.011) ? $obj->MAGIC : $obj;
113 ok($regexp->precomp() eq 'foo', 'Get string from qr//');
114 like($regexp->REGEX(), qr/\d+/, "REGEX() returns numeric value");
115 like($regexp->compflags, qr/^\d+\z/, "compflags returns numeric value");
116 is B::svref_2object(qr/(?{time})/)->qr_anoncv->ROOT->first->name, 'qr',
117   'qr_anoncv';
118 my $iv = 1;
119 my $iv_ref = B::svref_2object(\$iv);
120 is(ref $iv_ref, "B::IV", "Test B:IV return from svref_2object");
121 is($iv_ref->REFCNT, 1, "Test B::IV->REFCNT");
122 # Flag tests are needed still
123 #diag $iv_ref->FLAGS();
124 my $iv_ret = $iv_ref->object_2svref();
125 is(ref $iv_ret, "SCALAR", "Test object_2svref() return is SCALAR");
126 is($$iv_ret, $iv, "Test object_2svref()");
127 is($iv_ref->int_value, $iv, "Test int_value()");
128 is($iv_ref->IV, $iv, "Test IV()");
129 is($iv_ref->IVX(), $iv, "Test IVX()");
130 is($iv_ref->UVX(), $iv, "Test UVX()");
131 is(eval { $iv_ref->RV() }, undef, 'Test RV() on IV');
132 like($@, qr/argument is not SvROK/, 'Test RV() IV');
133 $iv = \"Pie";
134 my $val = eval { $iv_ref->RV() };
135 is(ref $val, 'B::PV', 'Test RV() on a reference');
136 is($val->PV(), 'Pie', 'Value expected');
137 is($@, '', "Test RV()");
138
139 my $pv = "Foo";
140 my $pv_ref = B::svref_2object(\$pv);
141 is(ref $pv_ref, "B::PV", "Test B::PV return from svref_2object");
142 is($pv_ref->REFCNT, 1, "Test B::PV->REFCNT");
143 # Flag tests are needed still
144 #diag $pv_ref->FLAGS();
145 my $pv_ret = $pv_ref->object_2svref();
146 is(ref $pv_ret, "SCALAR", "Test object_2svref() return is SCALAR");
147 is($$pv_ret, $pv, "Test object_2svref()");
148 is($pv_ref->PV(), $pv, "Test PV()");
149 is(eval { $pv_ref->RV() }, undef, 'Test RV() on PV');
150 like($@, qr/argument is not SvROK/, 'Test RV() on PV');
151 is($pv_ref->PVX(), $pv, "Test PVX()");
152 $pv = \"Pie";
153 $val = eval { $pv_ref->RV() };
154 is(ref $val, 'B::PV', 'Test RV() on a reference');
155 is($val->PV(), 'Pie', 'Value expected');
156 is($@, '', "Test RV()");
157
158 my $nv = 1.1;
159 my $nv_ref = B::svref_2object(\$nv);
160 is(ref $nv_ref, "B::NV", "Test B::NV return from svref_2object");
161 is($nv_ref->REFCNT, 1, "Test B::NV->REFCNT");
162 # Flag tests are needed still
163 #diag $nv_ref->FLAGS();
164 my $nv_ret = $nv_ref->object_2svref();
165 is(ref $nv_ret, "SCALAR", "Test object_2svref() return is SCALAR");
166 is($$nv_ret, $nv, "Test object_2svref()");
167 is($nv_ref->NV, $nv, "Test NV()");
168 is($nv_ref->NVX(), $nv, "Test NVX()");
169 is(eval { $nv_ref->RV() }, undef, 'Test RV() on NV');
170 like($@, qr/Can't locate object method "RV" via package "B::NV"/,
171      'Test RV() on NV');
172
173 my $null = undef;
174 my $null_ref = B::svref_2object(\$null);
175 is(ref $null_ref, "B::NULL", "Test B::NULL return from svref_2object");
176 is($null_ref->REFCNT, 1, "Test B::NULL->REFCNT");
177 # Flag tests are needed still
178 #diag $null_ref->FLAGS();
179 my $null_ret = $nv_ref->object_2svref();
180 is(ref $null_ret, "SCALAR", "Test object_2svref() return is SCALAR");
181 is($$null_ret, $nv, "Test object_2svref()");
182
183 my $RV_class = $] >= 5.011 ? 'B::IV' : 'B::RV';
184 my $cv = sub{ 1; };
185 my $cv_ref = B::svref_2object(\$cv);
186 is($cv_ref->REFCNT, 1, "Test $RV_class->REFCNT");
187 is(ref $cv_ref, "$RV_class",
188    "Test $RV_class return from svref_2object - code");
189 my $cv_ret = $cv_ref->object_2svref();
190 is(ref $cv_ret, "REF", "Test object_2svref() return is REF");
191 is($$cv_ret, $cv, "Test object_2svref()");
192
193 my $av = [];
194 my $av_ref = B::svref_2object(\$av);
195 is(ref $av_ref, "$RV_class",
196    "Test $RV_class return from svref_2object - array");
197
198 my $hv = [];
199 my $hv_ref = B::svref_2object(\$hv);
200 is(ref $hv_ref, "$RV_class",
201    "Test $RV_class return from svref_2object - hash");
202
203 local *gv = *STDOUT;
204 my $gv_ref = B::svref_2object(\*gv);
205 is(ref $gv_ref, "B::GV", "Test B::GV return from svref_2object");
206 ok(! $gv_ref->is_empty(), "Test is_empty()");
207 ok($gv_ref->isGV_with_GP(), "Test isGV_with_GP()");
208 is($gv_ref->NAME(), "gv", "Test NAME()");
209 is($gv_ref->SAFENAME(), "gv", "Test SAFENAME()");
210 like($gv_ref->FILE(), qr/b\.t$/, "Testing FILE()");
211 is($gv_ref->SvTYPE(), B::SVt_PVGV, "Test SvTYPE()");
212 is($gv_ref->FLAGS() & B::SVTYPEMASK, B::SVt_PVGV, "Test SVTYPEMASK");
213 is($gv_ref->GPFLAGS & B::GPf_ALIASED_SV, 0, 'GPFLAGS are unset');
214 {
215     local *gv = \my $x;
216     is($gv_ref->GPFLAGS & B::GPf_ALIASED_SV, B::GPf_ALIASED_SV,
217         'GPFLAGS gets GPf_ALIASED_SV set');
218 }    
219
220 # The following return B::SPECIALs.
221 is(ref B::sv_yes(), "B::SPECIAL", "B::sv_yes()");
222 is(ref B::sv_no(), "B::SPECIAL", "B::sv_no()");
223 is(ref B::sv_undef(), "B::SPECIAL", "B::sv_undef()");
224 SKIP: {
225     skip('no fork', 1)
226         unless ($Config::Config{d_fork} or $Config::Config{d_pseudofork});
227     my $pid;
228     if ($pid = fork) {
229         waitpid($pid,0);
230     }
231     else {
232         is(ref B::svref_2object(\(!!0)), "B::SPECIAL", "special SV table works after psuedofork");
233         exit;
234     }
235 }
236
237 # More utility functions
238 is(B::ppname(0), "pp_null", "Testing ppname (this might break if opnames.h is changed)");
239 is(B::opnumber("null"), 0, "Testing opnumber with opname (null)");
240 is(B::opnumber("pp_null"), 0, "Testing opnumber with opname (pp_null)");
241 {
242     my $hash = B::hash("wibble");
243     like($hash, qr/\A0x[0-9a-f]+\z/, "Testing B::hash(\"wibble\")");
244     unlike($hash, qr/\A0x0+\z/, "Testing B::hash(\"wibble\")");
245
246     SKIP: {
247         skip "Nulls don't hash to the same bucket regardless of length with this PERL_HASH implementation", 20
248             if B::hash("") ne B::hash("\0" x 19);
249         like(B::hash("\0" x $_), qr/\A0x0+\z/, "Testing B::hash(\"0\" x $_)")
250              for 0..19;
251     }
252
253     $hash = eval {B::hash(chr 256)};
254     is($hash, undef, "B::hash() refuses non-octets");
255     like($@, qr/^Wide character in subroutine entry/);
256
257     $hash = B::hash(chr 163);
258     my $str = chr(163) . chr 256;
259     chop $str;
260     is(B::hash($str), $hash, 'B::hash() with chr 128-256 is well-behaved');
261 }
262 {
263     is(B::cstring(undef), '0', "Testing B::cstring(undef)");
264     is(B::perlstring(undef), '0', "Testing B::perlstring(undef)");
265
266     my @common = map {eval $_, $_}
267         '"wibble"', '"\""', '"\'"', '"\\\\"', '"\\n\\r\\t\\b\\a\\f"', '"\000"',
268             '"\000\000"', '"\000Bing\000"', ord 'N' == 78 ? '"\\177"' : ();
269
270     my $oct = sprintf "\\%03o", ord '?';
271     my @tests = (@common, '$_', '"$_"', '@_', '"@_"', '??N', qq{"$oct?N"},
272                  ord 'N' == 78 ? (chr 11, '"\v"'): ());
273     while (my ($test, $expect) = splice @tests, 0, 2) {
274         is(B::cstring($test), $expect, "B::cstring($expect)");
275     }
276
277     @tests = (@common, '$_', '"\$_"', '@_', '"\@_"', '??N', '"??N"',
278               chr 256, '"\x{100}"', chr 65536, '"\x{10000}"',
279               ord 'N' == 78 ? (chr 11, '"\013"'): ());
280     while (my ($test, $expect) = splice @tests, 0, 2) {
281         is(B::perlstring($test), $expect, "B::perlstring($expect)");
282         utf8::upgrade $test;
283         $expect =~ s/\\b/sprintf("\\x{%x}", utf8::unicode_to_native(8))/eg;
284         $expect =~ s/\\([0-7]{3})/sprintf "\\x\{%x\}", oct $1/eg;
285         is(B::perlstring($test), $expect, "B::perlstring($expect) (Unicode)");
286     }
287 }
288 {
289     my @tests = ((map {eval(qq{"$_"}), $_} '\\n', '\\r', '\\t',
290                   '\\b', '\\a', '\\f', '\\000', '\\\'', '?'), '"', '"',
291                  ord 'N' == 78 ? (chr 11, '\v', "\177", '\\177') : ());
292
293     while (my ($test, $expect) = splice @tests, 0, 2) {
294         is(B::cchar($test), "'${expect}'", "B::cchar(qq{$expect})");
295     }
296 }
297
298 is(B::class(bless {}, "Wibble::Bibble"), "Bibble", "Testing B::class()");
299 is(B::cast_I32(3.14), 3, "Testing B::cast_I32()");
300 is(B::opnumber("chop"), $] >= 5.015 ? 39 : 38,
301                             "Testing opnumber with opname (chop)");
302
303 {
304     no warnings 'once';
305     my $sg = B::sub_generation();
306     *UNIVERSAL::hand_waving = sub { };
307     ok( $sg < B::sub_generation, "sub_generation increments" );
308 }
309
310 like( B::amagic_generation, qr/^\d+\z/, "amagic_generation" );
311
312 is(B::svref_2object(sub {})->ROOT->ppaddr, 'PL_ppaddr[OP_LEAVESUB]',
313    'OP->ppaddr');
314
315 # This one crashes from perl 5.8.9 to B 1.24 (perl 5.13.6):
316 B::svref_2object(sub{y/\x{100}//})->ROOT->first->first->sibling->sv;
317 ok 1, 'B knows that UTF trans is a padop in 5.8.9, not an svop';
318
319 {
320     my $o = B::svref_2object(sub{0;0})->ROOT->first->first;
321     # Make sure we are testing what we think we are testing.  If these two
322     # fail, tweak the test to find a nulled cop a different way.
323     is $o->name, "null", 'first op of sub{0;0} is a null';
324     is B::ppname($o->targ),'pp_nextstate','first op of sub{0;0} was a cop';
325     # Test its class
326     is B::class($o), "COP", 'nulled cops are of class COP';
327 }
328
329 {
330     format FOO =
331 foo
332 .
333     my $f = B::svref_2object(*FOO{FORMAT});
334     isa_ok $f, 'B::FM';
335     can_ok $f, 'LINES';
336 }
337
338 is B::safename("\cLAST_FH"), "^LAST_FH", 'basic safename test';
339
340 my $sub1 = sub {die};
341 { no warnings 'once'; no strict; *Peel:: = *{"Pe\0e\x{142}::"} }
342 my $sub2 = eval 'package Peel; sub {die}';
343 my $cop = B::svref_2object($sub1)->ROOT->first->first;
344 my $bobby = B::svref_2object($sub2)->ROOT->first->first;
345 is $cop->stash->object_2svref, \%main::, 'COP->stash';
346 is $cop->stashpv, 'main', 'COP->stashpv';
347
348 SKIP: {
349     skip "no nulls in packages before 5.17", 1 if $] < 5.017;
350     is $bobby->stashpv, "Pe\0e\x{142}", 'COP->stashpv with utf8 and nulls';
351 }
352
353 SKIP: {
354     skip "no stashoff", 2 if $] < 5.017 || !$Config::Config{useithreads};
355     like $cop->stashoff, qr/^[1-9]\d*\z/a, 'COP->stashoff';
356     isnt $cop->stashoff, $bobby->stashoff,
357         'different COP->stashoff for different stashes';
358 }
359
360 my $pmop = B::svref_2object(sub{ qr/fit/ })->ROOT->first->first->sibling;
361 $regexp = $pmop->pmregexp;
362 is B::class($regexp), 'REGEXP', 'B::PMOP::pmregexp returns a regexp';
363 is $regexp->precomp, 'fit', 'pmregexp returns the right regexp';
364
365
366 # Test $B::overlay
367 {
368     my $methods = {
369         BINOP =>  [ qw(last) ],
370         COP   =>  [ qw(arybase cop_seq file filegv hints hints_hash io
371                        label line stash stashpv
372                        stashoff warnings) ],
373         LISTOP => [ qw(children) ],
374         LOGOP =>  [ qw(other) ],
375         LOOP  =>  [ qw(lastop nextop redoop) ],
376         OP    =>  [ qw(desc flags name next opt ppaddr private sibling
377                        size spare targ type) ],
378         PADOP =>  [ qw(gv padix sv) ],
379         PMOP  =>  [ qw(code_list pmflags pmoffset pmreplroot pmreplstart pmstash pmstashpv precomp reflags) ],
380         PVOP  =>  [ qw(pv) ],
381         SVOP  =>  [ qw(gv sv) ],
382         UNOP  =>  [ qw(first) ],
383     };
384
385     my $overlay = {};
386     my $op = B::svref_2object(sub { my $x = 1 })->ROOT;
387
388     for my $class (sort keys %$methods) {
389         for my $meth (@{$methods->{$class}}) {
390             my $full = "B::${class}::$meth";
391             die "Duplicate method '$full'\n"
392                 if grep $_ eq $full, @{$overlay->{$meth}};
393             push @{$overlay->{$meth}}, "B::${class}::$meth";
394         }
395     }
396
397     {
398         local $B::overlay; # suppress 'used once' warning
399         local $B::overlay = { $$op => $overlay };
400
401         for my $class (sort keys %$methods) {
402             bless $op, "B::$class"; # naughty
403             for my $meth (@{$methods->{$class}}) {
404                 if ($op->can($meth)) {
405                     my $list = $op->$meth;
406                     ok(defined $list
407                             && ref($list) eq "ARRAY"
408                             && grep($_ eq "B::${class}::$meth", @$list),
409                         "overlay: B::$class $meth");
410                 }
411                 else {
412                     pass("overlay: B::$class $meth (skipped; no method)");
413                 }
414             }
415         }
416     }
417     # B::overlay should be disabled again here
418     is($op->name, "leavesub", "overlay: orig name");
419 }
420
421 { # [perl #118525]
422     {
423         sub foo {}
424         my $cv = B::svref_2object(\&foo);
425         ok($cv, "make a B::CV from a non-anon sub reference");
426         isa_ok($cv, "B::CV");
427         my $gv = $cv->GV;
428         ok($gv, "we get a GV from a GV on a normal sub");
429         isa_ok($gv, "B::GV");
430         is($gv->NAME, "foo", "check the GV name");
431       SKIP:
432         { # do we need these version checks?
433             skip "no HEK before 5.18", 1 if $] < 5.018;
434             is($cv->NAME_HEK, undef, "no hek for a global sub");
435         }
436     }
437
438 SKIP:
439     {
440         skip "no HEK before 5.18", 4 if $] < 5.018;
441         eval <<'EOS'
442     {
443         use feature 'lexical_subs';
444         no warnings 'experimental::lexical_subs';
445         my sub bar {};
446         my $cv = B::svref_2object(\&bar);
447         ok($cv, "make a B::CV from a lexical sub reference");
448         isa_ok($cv, "B::CV");
449         my $hek = $cv->NAME_HEK;
450         is($hek, "bar", "check the NAME_HEK");
451         my $gv = $cv->GV;
452         isa_ok($gv, "B::GV", "GV on a lexical sub");
453     }
454     1;
455 EOS
456           or die "lexical_subs test failed to compile: $@";
457     }
458 }
459
460 { # [perl #120535]
461     my %h = ( "\x{100}" => 1 );
462     my $b = B::svref_2object(\%h);
463     my ($k, $v) = $b->ARRAY;
464     is($k, "\x{100}", "check utf8 preserved by B::HV::ARRAY");
465 }
466
467 # test op_parent
468
469 SKIP: {
470     unless ($Config::Config{ccflags} =~ /PERL_OP_PARENT/) {
471         skip "op_parent only present with -DPERL_OP_PARENT builds", 6;
472     }
473     my $lineseq = B::svref_2object(sub{my $x = 1})->ROOT->first;
474     is ($lineseq->type,  B::opnumber('lineseq'),
475                                 'op_parent: top op is lineseq');
476     my $first  = $lineseq->first;
477     my $second = $first->sibling;
478     is(ref $second->sibling, "B::NULL", 'op_parent: second sibling is null');
479     is($first->lastsib,  0 , 'op_parent: first  sibling: !lastsib');
480     is($second->lastsib, 1,  'op_parent: second sibling: lastsib');
481     is($$lineseq,  ${$first->parent},   'op_parent: first  sibling okay');
482     is($$lineseq,  ${$second->parent},  'op_parent: second sibling okay');
483 }
484
485
486 # make sure ->sv, -gv methods do the right thing on threaded builds
487 {
488
489     # for some reason B::walkoptree only likes a sub name, not a code ref
490     my ($gv, $sv);
491     sub gvsv_const {
492         # make the early pad slots something unlike a threaded const or
493         # gvsv
494         my ($dummy1, $dummy2, $dummy3, $dummy4) = qw(foo1 foo2 foo3 foo4);
495         my $self = shift;
496         if ($self->name eq 'gvsv') {
497             $gv = $self->gv;
498         }
499         elsif ($self->name eq 'const') {
500             $sv = $self->sv;
501         }
502     };
503
504     B::walkoptree(B::svref_2object(sub {our $x = 1})->ROOT, "::gvsv_const");
505     ok(defined $gv, "gvsv->gv seen");
506     ok(defined $sv, "const->sv seen");
507     if ($Config::Config{useithreads}) {
508         # should get NULLs
509         is(ref($gv), "B::SPECIAL", "gvsv->gv is special");
510         is(ref($sv), "B::SPECIAL", "const->sv is special");
511         is($$gv, 0, "gvsv->gv special is 0 (NULL)");
512         is($$sv, 0, "const->sv special is 0 (NULL)");
513     }
514     else {
515         is(ref($gv), "B::GV", "gvsv->gv is GV");
516         is(ref($sv), "B::IV", "const->sv is IV");
517         pass();
518         pass();
519     }
520
521 }
522
523
524 # Some pad tests
525 {
526     my $sub = sub { my main $a; CORE::state @b; our %c };
527     my $padlist = B::svref_2object($sub)->PADLIST;
528     is $padlist->MAX, 1, 'padlist MAX';
529     my @array = $padlist->ARRAY;
530     is @array, 2, 'two items from padlist ARRAY';
531     is ${$padlist->ARRAYelt(0)}, ${$array[0]},
532       'ARRAYelt(0) is first item from ARRAY';
533     is ${$padlist->ARRAYelt(1)}, ${$array[1]},
534       'ARRAYelt(1) is second item from ARRAY';
535     is ${$padlist->NAMES}, ${$array[0]},
536       'NAMES is first item from ARRAY';
537     my @names = $array[0]->ARRAY;
538     cmp_ok @names, ">=", 4, 'at least 4 pad names';
539     is join(" ", map($_->PV//"undef",@names[0..3])), 'undef $a @b %c',
540        'pad name PVs';
541
542     my @closures;
543     for (1,2) { push @closures, sub { sub { @closures } } }
544     my $sub1 = B::svref_2object($closures[0]);
545     my $sub2 = B::svref_2object($closures[1]);
546     is $sub2->PADLIST->id, $sub1->PADLIST->id, 'padlist id';
547     $sub1 = B::svref_2object(my $lr = $closures[0]());
548     $sub2 = B::svref_2object(my $lr2= $closures[1]());
549     is $sub2->PADLIST->outid, $sub1->PADLIST->outid, 'padlist outid';
550 }
551
552
553 done_testing();