diff options
author | Jesse Luehrs <doy@tozt.net> | 2011-11-29 14:51:39 -0600 |
---|---|---|
committer | Jesse Luehrs <doy@tozt.net> | 2011-11-29 18:10:22 -0600 |
commit | c803b9210927bdf4a385070d386904a28e5f8540 (patch) | |
tree | 519a32d3315c207e5283940492d9c3c86d158304 /t/edge-cases.t | |
parent | 3bc2194c3cd03e95aabe5b57001ae5e6e6c85393 (diff) | |
download | package-stash-xs-c803b9210927bdf4a385070d386904a28e5f8540.tar.gz package-stash-xs-c803b9210927bdf4a385070d386904a28e5f8540.zip |
sync test suite
Diffstat (limited to 't/edge-cases.t')
-rwxr-xr-x | t/edge-cases.t | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/t/edge-cases.t b/t/edge-cases.t index 04e2164..262c13b 100755 --- a/t/edge-cases.t +++ b/t/edge-cases.t @@ -53,4 +53,40 @@ is(ref($constant), 'CODE', "expanded a constant into a coderef"); is(ref($stash->get_symbol('$glob')), '', "nothing yet"); is(ref($stash->get_or_add_symbol('$glob')), 'SCALAR', "got an empty scalar"); +SKIP: { + skip "PP doesn't support anon stashes before 5.14", 4 + if $] < 5.014 && $Package::Stash::IMPLEMENTATION eq 'PP'; + local $TODO = ($Package::Stash::IMPLEMENTATION eq 'PP') + ? "don't know how to properly inflate a stash entry" + : undef; + + my $anon = {}; # not using Package::Anon + $anon->{foo} = -1; # stub + $anon->{bar} = '$&'; # stub with prototype + $anon->{baz} = \"foo"; # constant + + my $stash = Package::Stash->new($anon); + is( + exception { + is(ref($stash->get_symbol('&foo')), 'CODE', + "stub expanded into a glob"); + is(ref($stash->get_symbol('&bar')), 'CODE', + "stub with prototype expanded into a glob"); + is(ref($stash->get_symbol('&baz')), 'CODE', + "constant expanded into a glob"); + }, + undef, + "can call get_symbol on weird stash entries" + ); +} + +{ + my $warning; + local $SIG{__WARN__} = sub { $warning = $_[0] }; + my $stash = Package::Stash->new('Bar'); + $stash->add_symbol('&foo' => sub { }); + $stash->add_symbol('&foo' => sub { }); + is($warning, undef, "no redefinition warnings"); +} + done_testing; |