11 use constant FOO => 1;
12 use constant BAR => \1;
13 use constant BAZ => [];
14 use constant QUUX => {};
15 use constant QUUUX => sub { };
18 sub normal_with_proto () { }
19 sub stub_with_proto ();
22 our $SCALAR_WITH_VALUE = 1;
27 my $stash = Package::Stash->new('Foo');
28 { local $TODO = $] < 5.010 ? "undef scalars aren't visible on 5.8" : undef;
29 ok($stash->has_symbol('$SCALAR'), '$SCALAR');
31 ok($stash->has_symbol('$SCALAR_WITH_VALUE'), '$SCALAR_WITH_VALUE');
32 ok($stash->has_symbol('@ARRAY'), '@ARRAY');
33 ok($stash->has_symbol('%HASH'), '%HASH');
35 [sort $stash->list_all_symbols('CODE')],
36 [qw(BAR BAZ FOO QUUUX QUUX normal normal_with_proto stub stub_with_proto)],
37 "can see all code symbols"
40 $stash->add_symbol('%added', {});
41 ok(!$stash->has_symbol('$added'), '$added');
42 ok(!$stash->has_symbol('@added'), '@added');
43 ok($stash->has_symbol('%added'), '%added');
45 my $constant = $stash->get_symbol('&FOO');
46 is(ref($constant), 'CODE', "expanded a constant into a coderef");