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