X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=t%2Flib%2FSharedTests.pm;h=d9e6cca218811bfb957618e47c134d7b82ca069e;hb=7a4a3b1efe4db788811154fbecbf6c94ceeee4bf;hp=9df7a6e14aa30771bf8c81ec0e3c3889b4ba2282;hpb=5091e7b52c1532d96210b3fe0779c831b5e4eb30;p=gitmo%2FMooseX-ClassAttribute.git diff --git a/t/lib/SharedTests.pm b/t/lib/SharedTests.pm index 9df7a6e..d9e6cca 100644 --- a/t/lib/SharedTests.pm +++ b/t/lib/SharedTests.pm @@ -9,14 +9,13 @@ use Test::More; my $HasMXAH; BEGIN { - if ( eval 'use MooseX::AttributeHelpers 0.09; 1;' ) + if ( eval 'use MooseX::AttributeHelpers 0.13; 1;' ) { $HasMXAH = 1; } } -plan tests => 25; - +sub HasMXAH { $HasMXAH } { package HasClassAttribute; @@ -67,10 +66,13 @@ plan tests => 25; ( is => 'rw', isa => 'Delegatee', handles => [ 'units', 'color' ], + # if it's not lazy it makes a new object before we define + # Delegatee's attributes. + lazy => 1, default => sub { Delegatee->new() }, ); - if ($HasMXAH) + if ( SharedTests->HasMXAH() ) { class_has 'Mapping' => ( metaclass => 'Collection::Hash', @@ -93,7 +95,6 @@ plan tests => 25; ); no Moose; - no MooseX::ClassAttribute; sub BUILD { @@ -107,7 +108,6 @@ plan tests => 25; my $class = shift; $class->meta()->make_immutable(); - MooseX::ClassAttribute::container_class()->meta()->make_immutable(); Delegatee->meta()->make_immutable(); } } @@ -126,6 +126,8 @@ plan tests => 25; ( is => 'ro', default => 'blue', ); + + no Moose; } { @@ -138,10 +140,19 @@ plan tests => 25; class_has '+ReadOnlyAttribute' => ( default => 30 ); + + class_has 'YetAnotherAttribute' => + ( is => 'ro', + default => 'thing', + ); + + no Moose; } sub run_tests { + plan tests => 24; + local $Test::Builder::Level = $Test::Builder::Level + 1; { @@ -228,15 +239,10 @@ sub run_tests 'units() delegates to Delegatee and returns 5' ); } - { - ok( ! HasClassAttribute->can('class_has'), - q{'no MooseX::ClassAttribute' remove class_has from HasClassAttribute} ); - } - SKIP: { skip 'These tests require MooseX::AttributeHelpers', 4 - unless $HasMXAH; + unless SharedTests->HasMXAH(); my @ids = HasClassAttribute->IdsInMapping(); is( scalar @ids, 0,