1use strict; 2use warnings; 3use Test::More; 4use Test::Fatal; 5use lib 't/lib'; 6 7use Package::Stash; 8 9BEGIN { 10 plan skip_all => "Anonymous stashes in PP need at least perl 5.14" 11 if $] < 5.014 12 && $Package::Stash::IMPLEMENTATION eq 'PP'; 13 14 plan skip_all => "This isn't really going to work yet, probably"; 15} 16 17use Symbol; 18 19my $anon = {}; 20my $stash = Package::Stash->new($anon); 21# no way to bless something into a hashref yet 22# my $obj = $anon->bless({}); 23 24{ 25 my $code = sub { 'FOO' }; 26 $stash->add_symbol('&foo' => $code); 27 is($stash->get_symbol('&foo'), $code); 28 # is($obj->foo, 'FOO'); 29} 30 31{ 32 local $TODO = "can't inflate weird stash entries"; 33 $anon->{bar} = \123; 34 35 is( 36 exception { 37 my $code = $stash->get_symbol('&bar'); 38 is(ref($code), 'CODE'); 39 is($code->(), 123); 40 41 # is($obj->bar, 123); 42 }, 43 undef 44 ); 45} 46 47{ 48 local $TODO = "can't inflate weird stash entries"; 49 $anon->{baz} = -1; 50 51 is( 52 exception { 53 my $code = $stash->get_symbol('&baz'); 54 is(ref($code), 'CODE'); 55 like( 56 exception { $code->() }, 57 qr/Undefined subroutine \&__ANON__::baz called/ 58 ); 59 }, 60 undef 61 ); 62} 63 64done_testing; 65