6 if (($Config::Config{'extensions'} !~ /\bB\b/) ){
7 print "1..0 # Skip -- Perl configured without B module\n";
16 BEGIN { use_ok( 'B' ); }
18 # Somewhat minimal tests.
24 return ++$seen{$self->name};
28 sub B::OP::walkoptree_debug {
30 return ++$debug{$self->name};
34 # This gives us a substcont, which gets to the second recursive call
35 # point (in the if statement in the XS code)
37 # PMOP_pmreplroot(cPMOPo) is NULL for this
39 # This gives an OP_PUSHRE
43 is (B::walkoptree_debug, 0, 'walkoptree_debug() is 0');
44 B::walkoptree(B::svref_2object($victim)->ROOT, "pie");
45 foreach (qw(substcont pushre split leavesub)) {
46 is ($seen{$_}, 1, "Our victim had a $_ OP");
48 is_deeply ([keys %debug], [], 'walkoptree_debug was not called');
50 B::walkoptree_debug(2);
51 is (B::walkoptree_debug, 1, 'walkoptree_debug() is 1');
54 B::walkoptree(B::svref_2object($victim)->ROOT, "pie");
55 foreach (qw(substcont pushre split leavesub)) {
56 is ($seen{$_}, 1, "Our victim had a $_ OP");
58 is_deeply (\%debug, \%seen, 'walkoptree_debug was called correctly');
62 # Now try to exercise the code in walkoptree that decides that it can't re-use
63 # the object and reference.
65 my $name = $_[0]->name;
68 # Take another reference to the reference
70 } elsif ($name =~ /^p/) {
71 # Take another reference to the object
72 push @::junk, \${$_[0]};
73 } elsif ($name =~ /^l/) {
75 } elsif ($name =~ /g/) {
76 ${$_[0]} = "Muhahahahaha!";
77 } elsif ($name =~ /^c/) {
82 B::walkoptree(B::svref_2object($victim)->ROOT, "fiddle");
83 is_deeply (\%seen2, \%seen, 'everything still seen');