b9b3d0b6db54db2e4856942cf0b0d9ac240fe8ea
[gitmo/Mouse.git] / t / 001_mouse / 062-package-symbol.t
1 #!perl
2 use strict;
3 use warnings;
4
5 use Test::More;
6
7 {
8     package Foo;
9     use Mouse;
10
11     sub code { 42 }
12
13     our $scalar = 'bar';
14
15     our %hash = (a => 'b');
16
17     our @array = ('foo');
18 }
19
20 my $meta = Foo->meta;
21
22 foreach my $sym(qw(&code $scalar %hash @array)){
23     ok $meta->has_package_symbol($sym),      "has_package_symbol('$sym')";
24 }
25
26 ok !$meta->has_package_symbol('$hogehoge');
27 ok !$meta->has_package_symbol('%array');
28
29 is $meta->get_package_symbol('&code'),   \&Foo::code;
30 is $meta->get_package_symbol('$scalar'), \$Foo::scalar;
31 is $meta->get_package_symbol('%hash'),   \%Foo::hash;
32 is $meta->get_package_symbol('@array'),  \@Foo::array;
33
34 is $meta->get_package_symbol('@hogehoge'), undef;
35 is $meta->get_package_symbol('%array'),    undef;
36 is $meta->get_package_symbol('&hash'),     undef;
37
38 done_testing;