Skip to content

Commit

Permalink
Add tests to make sure that changing the stash is reflected in the ca…
Browse files Browse the repository at this point in the history
…ched namespace
  • Loading branch information
autarch committed Aug 27, 2010
1 parent 6f0d8b6 commit 0a5166a
Showing 1 changed file with 54 additions and 0 deletions.
54 changes: 54 additions & 0 deletions t/01-basic.t
Expand Up @@ -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;

0 comments on commit 0a5166a

Please sign in to comment.