disable bare anon stash tests for now
[gitmo/Package-Stash.git] / t / bare-anon.t
CommitLineData
c6ddb1d1 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"
acbc69c4 12 if $] < 5.014
ace6563d 13 && $Package::Stash::IMPLEMENTATION eq 'PP';
c6ddb1d1 14
e068010b 15plan skip_all => "This isn't really going to work yet, probably";
16
c6ddb1d1 17my $anon = {};
18my $stash = Package::Stash->new($anon);
19# no way to bless something into a hashref yet
20# my $obj = $anon->bless({});
21
22{
23 my $code = sub { 'FOO' };
24 $stash->add_symbol('&foo' => $code);
25 is($stash->get_symbol('&foo'), $code);
26 # is($obj->foo, 'FOO');
27}
28
29{
30 local $TODO = ($Package::Stash::IMPLEMENTATION eq 'PP')
31 ? "can't inflate weird stash entries"
32 : undef;
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 = ($Package::Stash::IMPLEMENTATION eq 'PP')
49 ? "can't inflate weird stash entries"
50 : undef;
51 $anon->{baz} = -1;
52
53 is(
54 exception {
55 my $code = $stash->get_symbol('&baz');
56 is(ref($code), 'CODE');
57 like(
58 exception { $code->() },
59 qr/Undefined subroutine \&__ANON__::baz called/
60 );
61 },
62 undef
63 );
64}
65
66done_testing;