Commit | Line | Data |
56a29840 |
1 | #!/usr/bin/env perl |
2 | use strict; |
3 | use warnings; |
2905fb35 |
4 | use lib 't/lib'; |
56a29840 |
5 | use Test::More; |
13f4d7c3 |
6 | use Test::Fatal; |
56a29840 |
7 | |
8 | { |
9 | package Foo; |
10 | open *foo, "<", $0; |
11 | |
12 | sub foo { } |
13 | } |
14 | |
15 | { |
16 | package Bar; |
17 | open *bar, "<", $0; |
18 | |
19 | sub bar { } |
20 | } |
21 | |
e94260da |
22 | use Package::Stash; |
56a29840 |
23 | |
24 | { |
e94260da |
25 | my $stash = Package::Stash->new('Foo'); |
2905fb35 |
26 | ok($stash->has_symbol('&foo'), "has &foo"); |
27 | ok($stash->has_symbol('foo'), "has foo"); |
28 | $stash->remove_symbol('&foo'); |
29 | ok(!$stash->has_symbol('&foo'), "has &foo"); |
30 | ok($stash->has_symbol('foo'), "has foo"); |
56a29840 |
31 | } |
32 | |
33 | { |
e94260da |
34 | my $stash = Package::Stash->new('Bar'); |
2905fb35 |
35 | ok($stash->has_symbol('&bar'), "has &bar"); |
36 | ok($stash->has_symbol('bar'), "has bar"); |
37 | $stash->remove_symbol('bar'); |
38 | ok($stash->has_symbol('&bar'), "has &bar"); |
39 | ok(!$stash->has_symbol('bar'), "has bar"); |
56a29840 |
40 | } |
41 | |
42 | { |
e94260da |
43 | my $stash = Package::Stash->new('Baz'); |
2905fb35 |
44 | is(exception { |
45 | $stash->add_symbol('baz', *Foo::foo{IO}); |
46 | }, undef, "can add an IO symbol"); |
47 | ok($stash->has_symbol('baz'), "has baz"); |
48 | is($stash->get_symbol('baz'), *Foo::foo{IO}, "got the right baz"); |
56a29840 |
49 | } |
50 | |
51 | done_testing; |