6 @INC = qw(: ::lib ::macos:lib);
16 use Test::More tests => 5;
18 BEGIN { use_ok( 'B' ); }
21 package Testing::Symtable;
22 use vars qw($This @That %wibble $moo %moo);
23 my $not_a_sym = 'moo';
29 package Testing::Symtable::Foo;
32 package Testing::Symtable::Bar;
38 B::walksymtable(\%Testing::Symtable::, 'find_syms', sub { $_[0] =~ /Foo/ },
39 'Testing::Symtable::');
41 sub B::GV::find_syms {
44 $main::Subs{$symbol->STASH->NAME . '::' . $symbol->NAME}++;
47 my @syms = map { 'Testing::Symtable::'.$_ } qw(This That wibble moo car
49 push @syms, "Testing::Symtable::Foo::yarrow";
51 # Make sure we hit all the expected symbols.
52 ok( join('', sort @syms) eq join('', sort keys %Subs), 'all symbols found' );
54 # Make sure we only hit them each once.
55 ok( (!grep $_ != 1, values %Subs), '...and found once' );
57 # Tests for MAGIC / MOREMAGIC
58 ok( B::svref_2object(\$.)->MAGIC->TYPE eq "\0", '$. has \0 magic' );
61 local $SIG{__DIE__} = sub { $e = $_[0] };
62 # Used to dump core, bug #16828
63 eval { B::svref_2object(\$.)->MAGIC->MOREMAGIC->TYPE; };
64 like( $e, qr/Can't call method "TYPE" on an undefined value/,
65 '$. has no more magic' );