summaryrefslogtreecommitdiffstats
path: root/t
diff options
context:
space:
mode:
authorJesse Luehrs <doy@tozt.net>2010-11-14 13:25:57 -0600
committerJesse Luehrs <doy@tozt.net>2010-11-14 13:25:57 -0600
commitd2b55565cb3bbafd9923c9b67e021bcf09c7eaa7 (patch)
treeb8428b6303336e52a90eae5a5cfcea27df9afc5d /t
parent60b395a1c2f7efdba256d7886ad86a0a9fb87e9d (diff)
downloadpackage-stash-xs-d2b55565cb3bbafd9923c9b67e021bcf09c7eaa7.tar.gz
package-stash-xs-d2b55565cb3bbafd9923c9b67e021bcf09c7eaa7.zip
implement get_all_symbols
Diffstat (limited to 't')
-rw-r--r--t/01-basic.t46
-rw-r--r--t/20-leaks.t16
2 files changed, 62 insertions, 0 deletions
diff --git a/t/01-basic.t b/t/01-basic.t
index 4c4a7c9..6b85515 100644
--- a/t/01-basic.t
+++ b/t/01-basic.t
@@ -226,6 +226,52 @@ is($foo_stash->get_symbol('@foo'), $ARRAY, '... got the right values for @Foo::f
ok(defined(*{"Foo::foo"}{ARRAY}), '... the @foo slot has NOT been removed');
}
+{
+ my $syms = $foo_stash->get_all_symbols;
+ is_deeply(
+ [ sort keys %{ $syms } ],
+ [ sort $foo_stash->list_all_symbols ],
+ '... the fetched symbols are the same as the listed ones'
+ );
+}
+
+{
+ my $syms = $foo_stash->get_all_symbols('CODE');
+
+ is_deeply(
+ [ sort keys %{ $syms } ],
+ [ sort $foo_stash->list_all_symbols('CODE') ],
+ '... the fetched symbols are the same as the listed ones'
+ );
+
+ foreach my $symbol (keys %{ $syms }) {
+ is($syms->{$symbol}, $foo_stash->get_symbol('&' . $symbol), '... got the right symbol');
+ }
+}
+
+{
+ $foo_stash->add_symbol('%zork');
+
+ my $syms = $foo_stash->get_all_symbols('HASH');
+
+ is_deeply(
+ [ sort keys %{ $syms } ],
+ [ sort $foo_stash->list_all_symbols('HASH') ],
+ '... the fetched symbols are the same as the listed ones'
+ );
+
+ foreach my $symbol (keys %{ $syms }) {
+ is($syms->{$symbol}, $foo_stash->get_symbol('%' . $symbol), '... got the right symbol');
+ }
+
+ no warnings 'once';
+ is_deeply(
+ $syms,
+ { zork => \%Foo::zork },
+ "got the right ones",
+ );
+}
+
# check some errors
like(exception {
diff --git a/t/20-leaks.t b/t/20-leaks.t
index 3954b15..d5dae8a 100644
--- a/t/20-leaks.t
+++ b/t/20-leaks.t
@@ -143,6 +143,22 @@ use Symbol;
} "list_all_symbols doesn't leak";
}
+{
+ package Blah;
+ use constant 'baz';
+}
+
+{
+ my $foo = Package::Stash->new('Foo');
+ my $blah = Package::Stash->new('Blah');
+ no_leaks_ok {
+ $foo->get_all_symbols;
+ $foo->get_all_symbols('SCALAR');
+ $foo->get_all_symbols('CODE');
+ $blah->get_all_symbols('CODE');
+ } "list_all_symbols doesn't leak";
+}
+
# mimic CMOP::create_anon_class
{
local $TODO = $] < 5.010 ? "deleting stashes is inherently leaky on 5.8"