X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=t%2F080_meta_package.t;h=e3987417ed76e2c3f0d25ac09d7b2ede00b4ad8d;hb=c20522bd825495befde91f3201a71909d80dd31c;hp=3a0efbd1fa33dc291c585c19140c85ceede1182d;hpb=d326817e362a991b24186cf6e9fa9de93beb11c3;p=gitmo%2FClass-MOP.git diff --git a/t/080_meta_package.t b/t/080_meta_package.t index 3a0efbd..e398741 100644 --- a/t/080_meta_package.t +++ b/t/080_meta_package.t @@ -3,7 +3,7 @@ use strict; use warnings; -use Test::More tests => 34; +use Test::More tests => 43; use Test::Exception; BEGIN { @@ -24,11 +24,27 @@ lives_ok { Foo->meta->add_package_symbol('%foo' => { one => 1 }); } '... created %Foo::foo successfully'; +ok(!Foo->meta->has_package_symbol('$foo'), '... SCALAR shouldnt have been created too'); + ok(defined($Foo::{foo}), '... the %foo slot was created successfully'); ok(Foo->meta->has_package_symbol('%foo'), '... the meta agrees'); { no strict 'refs'; + ok(defined(*{"Foo::foo"}{HASH}), '... the %foo (HASH) slot was created successfully'); + + ok(!defined(*{"Foo::foo"}{SCALAR}), '... but the $foo slot was not created'); + ok(!Foo->meta->has_package_symbol('$foo'), '... and the meta agrees'); + + ok(!defined(*{"Foo::foo"}{ARRAY}), '... but the @foo slot was not created'); + ok(!Foo->meta->has_package_symbol('@foo'), '... and the meta agrees'); + + ok(!defined(*{"Foo::foo"}{CODE}), '... but the &foo slot was not created'); + ok(!Foo->meta->has_package_symbol('&foo'), '... and the meta agrees'); +} + +{ + no strict 'refs'; ok(exists ${'Foo::foo'}{one}, '... our %foo was initialized correctly'); is(${'Foo::foo'}{one}, 1, '... our %foo was initialized correctly'); } @@ -99,6 +115,11 @@ lives_ok { ok(Foo->meta->has_package_symbol('%foo'), '... the %foo slot was removed successfully'); +{ + no strict 'refs'; + ok(!defined(*{"Foo::foo"}{HASH}), '... the %foo slot has been removed successfully'); +} + # check some errors dies_ok { @@ -116,8 +137,3 @@ dies_ok { dies_ok { Foo->meta->has_package_symbol('bar'); } '... no sigil for bar'; - - -#dies_ok { -# Foo->meta->get_package_symbol('@.....bar'); -#} '... could not fetch variable';