6 use Test::More tests => 33;
18 ok(!defined($Foo::{foo}), '... the %foo slot has not been created yet');
19 ok(!Foo->meta->has_package_symbol('%foo'), '... the meta agrees');
22 Foo->meta->add_package_symbol('%foo' => { one => 1 });
23 } '... created %Foo::foo successfully';
25 ok(defined($Foo::{foo}), '... the %foo slot was created successfully');
26 ok(Foo->meta->has_package_symbol('%foo'), '... the meta agrees');
30 ok(exists ${'Foo::foo'}{one}, '... our %foo was initialized correctly');
31 is(${'Foo::foo'}{one}, 1, '... our %foo was initialized correctly');
34 my $foo = Foo->meta->get_package_symbol('%foo');
35 is_deeply({ one => 1 }, $foo, '... got the right package variable back');
41 is(\%{'Foo::foo'}, Foo->meta->get_package_symbol('%foo'), '... our %foo is the same as the metas');
43 ok(exists ${'Foo::foo'}{two}, '... our %foo was updated correctly');
44 is(${'Foo::foo'}{two}, 2, '... our %foo was updated correctly');
47 ok(!defined($Foo::{bar}), '... the @bar slot has not been created yet');
50 Foo->meta->add_package_symbol('@bar' => [ 1, 2, 3 ]);
51 } '... created @Foo::bar successfully';
53 ok(defined($Foo::{bar}), '... the @bar slot was created successfully');
57 is(scalar @{'Foo::bar'}, 3, '... our @bar was initialized correctly');
58 is(${'Foo::bar'}[1], 2, '... our @bar was initialized correctly');
61 # now without initial value
63 ok(!defined($Foo::{baz}), '... the %baz slot has not been created yet');
66 Foo->meta->add_package_symbol('%baz');
67 } '... created %Foo::baz successfully';
69 ok(defined($Foo::{baz}), '... the %baz slot was created successfully');
73 ${'Foo::baz'}{one} = 1;
75 ok(exists ${'Foo::baz'}{one}, '... our %baz was initialized correctly');
76 is(${'Foo::baz'}{one}, 1, '... our %baz was initialized correctly');
79 ok(!defined($Foo::{bling}), '... the @bling slot has not been created yet');
82 Foo->meta->add_package_symbol('@bling');
83 } '... created @Foo::bling successfully';
85 ok(defined($Foo::{bling}), '... the @bling slot was created successfully');
89 is(scalar @{'Foo::bling'}, 0, '... our @bling was initialized correctly');
90 ${'Foo::bling'}[1] = 2;
91 is(${'Foo::bling'}[1], 2, '... our @bling was assigned too correctly');
95 Foo->meta->remove_package_symbol('%foo');
96 } '... removed %Foo::foo successfully';
98 ok(Foo->meta->has_package_symbol('%foo'), '... the %foo slot was removed successfully');
103 Foo->meta->add_package_symbol('bar');
104 } '... no sigil for bar';
107 Foo->meta->remove_package_symbol('bar');
108 } '... no sigil for bar';
111 Foo->meta->get_package_symbol('bar');
112 } '... no sigil for bar';
115 Foo->meta->has_package_symbol('bar');
116 } '... no sigil for bar';
120 # Foo->meta->get_package_symbol('@.....bar');
121 #} '... could not fetch variable';