summaryrefslogtreecommitdiff
path: root/ext
diff options
context:
space:
mode:
authorFather Chrysostomos <sprout@cpan.org>2014-12-23 08:46:32 -0800
committerFather Chrysostomos <sprout@cpan.org>2014-12-23 09:22:16 -0800
commit1d7705d58a848edcf0236cbc1bdf530dd5e29742 (patch)
treed73fbe6b1b171376c9cc446ae42f637bd4fce494 /ext
parent58480c3bbb1698b786ac0f8efe76d20625ddbcdd (diff)
downloadperl-1d7705d58a848edcf0236cbc1bdf530dd5e29742.tar.gz
Some B pad tests
Diffstat (limited to 'ext')
-rw-r--r--ext/B/t/b.t29
1 files changed, 29 insertions, 0 deletions
diff --git a/ext/B/t/b.t b/ext/B/t/b.t
index e2d644a093..0c1a0f33ac 100644
--- a/ext/B/t/b.t
+++ b/ext/B/t/b.t
@@ -505,4 +505,33 @@ SKIP: {
}
+# Some pad tests
+{
+ my $sub = sub { my main $a; CORE::state @b; our %c };
+ my $padlist = B::svref_2object($sub)->PADLIST;
+ is $padlist->MAX, 1, 'padlist MAX';
+ my @array = $padlist->ARRAY;
+ is @array, 2, 'two items from padlist ARRAY';
+ is ${$padlist->ARRAYelt(0)}, ${$array[0]},
+ 'ARRAYelt(0) is first item from ARRAY';
+ is ${$padlist->ARRAYelt(1)}, ${$array[1]},
+ 'ARRAYelt(1) is second item from ARRAY';
+ is ${$padlist->NAMES}, ${$array[0]},
+ 'NAMES is first item from ARRAY';
+ my @names = $array[0]->ARRAY;
+ cmp_ok @names, ">=", 4, 'at least 4 pad names';
+ is join(" ", map($_->PV//"undef",@names[0..3])), 'undef $a @b %c',
+ 'pad name PVs';
+
+ my @closures;
+ for (1,2) { push @closures, sub { sub { @closures } } }
+ my $sub1 = B::svref_2object($closures[0]);
+ my $sub2 = B::svref_2object($closures[1]);
+ is $sub2->PADLIST->id, $sub1->PADLIST->id, 'padlist id';
+ $sub1 = B::svref_2object(my $lr = $closures[0]());
+ $sub2 = B::svref_2object(my $lr2= $closures[1]());
+ is $sub2->PADLIST->outid, $sub1->PADLIST->outid, 'padlist outid';
+}
+
+
done_testing();