summaryrefslogtreecommitdiffstats
path: root/t/01-basic.t
diff options
context:
space:
mode:
authorDave Rolsky <autarch@urth.org>2010-08-27 10:27:24 -0500
committerDave Rolsky <autarch@urth.org>2010-08-27 10:27:24 -0500
commit0a5166afdae1044a3722b5d241ecdc3228dbd370 (patch)
treeb7a8bd041856241eeec5e04181d1b7350664c5c4 /t/01-basic.t
parent6f0d8b6729ef78bd9f7aa1c82842b2817aa99d1e (diff)
downloadpackage-stash-0a5166afdae1044a3722b5d241ecdc3228dbd370.tar.gz
package-stash-0a5166afdae1044a3722b5d241ecdc3228dbd370.zip
Add tests to make sure that changing the stash is reflected in the cached namespace
Diffstat (limited to 't/01-basic.t')
-rw-r--r--t/01-basic.t54
1 files changed, 54 insertions, 0 deletions
diff --git a/t/01-basic.t b/t/01-basic.t
index efd82b4..5112b11 100644
--- a/t/01-basic.t
+++ b/t/01-basic.t
@@ -270,4 +270,58 @@ dies_ok {
is($stash->get_package_symbol('foo'), *Baz::foo{IO}, "got foo");
}
+{
+ package Quux;
+
+ our $foo = 23;
+ our @foo = "bar";
+ our %foo = (baz => 1);
+ sub foo { }
+ open *foo, '<', $0;
+}
+
+{
+ my $stash = Package::Stash->new('Quux');
+
+ my %expect = (
+ '$foo' => \23,
+ '@foo' => ["bar"],
+ '%foo' => { baz => 1 },
+ '&foo' => \&Quux::foo,
+ 'foo' => *Quux::foo{IO},
+ );
+
+ for my $sym ( sort keys %expect ) {
+ is_deeply(
+ $stash->get_package_symbol($sym),
+ $expect{$sym},
+ "got expected value for $sym"
+ );
+ }
+
+ $stash->add_package_symbol('%bar' => {x => 42});
+
+ $expect{'%bar'} = {x => 42};
+
+ for my $sym ( sort keys %expect ) {
+ is_deeply(
+ $stash->get_package_symbol($sym),
+ $expect{$sym},
+ "got expected value for $sym"
+ );
+ }
+
+ $stash->add_package_symbol('%bar' => {x => 43});
+
+ $expect{'%bar'} = {x => 43};
+
+ for my $sym ( sort keys %expect ) {
+ is_deeply(
+ $stash->get_package_symbol($sym),
+ $expect{$sym},
+ "got expected value for $sym"
+ );
+ }
+}
+
done_testing;