diff options
Diffstat (limited to 't/magic.t')
-rw-r--r-- | t/magic.t | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/t/magic.t b/t/magic.t new file mode 100644 index 0000000..4318f58 --- /dev/null +++ b/t/magic.t @@ -0,0 +1,32 @@ +#!/usr/bin/env perl +use strict; +use warnings; +use lib 't/lib'; +use Test::More; + +use Package::Stash; + +# @ISA magic +{ + my $Foo = Package::Stash->new('ISAFoo'); + $Foo->add_symbol('&foo' => sub { }); + + my $Bar = Package::Stash->new('ISABar'); + @{ $Bar->get_or_add_symbol('@ISA') } = ('ISAFoo'); + can_ok('ISABar', 'foo'); + + my $Foo2 = Package::Stash->new('ISAFoo2'); + $Foo2->add_symbol('&foo2' => sub { }); + @{ $Bar->get_or_add_symbol('@ISA') } = ('ISAFoo2'); + can_ok('ISABar', 'foo2'); + ok(!Bar->can('foo')); +} + +{ + my $main = Package::Stash->new('main'); + $main->add_symbol('$"', '-'); + my @foo = qw(a b c); + is(eval q["@foo"], 'a-b-c'); +} + +done_testing; |