summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJesse Luehrs <doy@tozt.net>2013-01-03 18:32:52 -0600
committerJesse Luehrs <doy@tozt.net>2013-01-03 19:06:40 -0600
commit545ac8af4f349ec57acb6456a54655504b4afb43 (patch)
tree9cefea4e09c97ebf270f6cd69045c9e65b4a8e63
parent63ba28a1a1657ff4a6e8039f43a5c58c535ca6f1 (diff)
downloadpackage-stash-xs-545ac8af4f349ec57acb6456a54655504b4afb43.tar.gz
package-stash-xs-545ac8af4f349ec57acb6456a54655504b4afb43.zip
add test for magic behavior
-rw-r--r--t/magic.t32
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;