6 @INC = qw(: ::lib ::macos:lib);
12 if (($Config::Config{'extensions'} !~ /\bB\b/) ){
13 print "1..0 # Skip -- Perl configured without B module\n";
21 use Test::More tests => 5;
23 BEGIN { use_ok( 'B' ); }
26 package Testing::Symtable;
27 use vars qw($This @That %wibble $moo %moo);
28 my $not_a_sym = 'moo';
34 package Testing::Symtable::Foo;
37 package Testing::Symtable::Bar;
43 B::walksymtable(\%Testing::Symtable::, 'find_syms', sub { $_[0] =~ /Foo/ },
44 'Testing::Symtable::');
46 sub B::GV::find_syms {
49 $main::Subs{$symbol->STASH->NAME . '::' . $symbol->NAME}++;
52 my @syms = map { 'Testing::Symtable::'.$_ } qw(This That wibble moo car
54 push @syms, "Testing::Symtable::Foo::yarrow";
56 # Make sure we hit all the expected symbols.
57 ok( join('', sort @syms) eq join('', sort keys %Subs), 'all symbols found' );
59 # Make sure we only hit them each once.
60 ok( (!grep $_ != 1, values %Subs), '...and found once' );
62 # Tests for MAGIC / MOREMAGIC
63 ok( B::svref_2object(\$.)->MAGIC->TYPE eq "\0", '$. has \0 magic' );
66 local $SIG{__DIE__} = sub { $e = $_[0] };
67 # Used to dump core, bug #16828
68 eval { B::svref_2object(\$.)->MAGIC->MOREMAGIC->TYPE; };
69 like( $e, qr/Can't call method "TYPE" on an undefined value/,
70 '$. has no more magic' );