From: Kent Fredric Date: Tue, 23 Apr 2013 19:48:00 +0000 (+1200) Subject: add xt/ test for RT#84615 : Moo::Object->meta->can() dies X-Git-Tag: v1.002000~14 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=f1bad247e7bea8015d4d57f66c7e033b52d513a4;p=gitmo%2FMoo.git add xt/ test for RT#84615 : Moo::Object->meta->can() dies Add a test for people doing simple inheritance of Moo::Object, which also exhibits RT#84615 Add Haargs test case which is seemingly more common than the other two combined. get_all_attributes even works as expected! --- diff --git a/xt/moo-object-meta-can.t b/xt/moo-object-meta-can.t new file mode 100644 index 0000000..3bc4f21 --- /dev/null +++ b/xt/moo-object-meta-can.t @@ -0,0 +1,49 @@ +#!/usr/bin/env perl +use strict; +use warnings; +use Test::More; +use Test::Fatal; +use Moo::Object; + +# See RT#84615 + +ok( Moo::Object->can('meta'), 'Moo::Object can meta'); +is( exception { Moo::Object->meta->can('can') } , undef, "Moo::Object->meta->can doesn't explode" ); + +{ + package Example; + use base 'Moo::Object'; + +} + +ok( Example->can('meta'), 'Example can meta'); +is( exception { Example->meta->can('can') } , undef, "Example->meta->can doesn't explode" ); + +# Haarg++ noting that previously, this *also* would have died due to its absence from %Moo::Makers; +{ + package Example_2; + use Moo; + + has 'attr' => ( is => ro =>, ); + + $INC{'Example_2.pm'} = 1; +} +{ + package Example_3; + use base "Example_2"; +} + +ok( Example_2->can('meta'), 'Example_2 can meta') and subtest meta_checks_for_Example_2 => sub { + return unless ok( Example_2->meta->can('get_all_attributes'), 'Example_2 meta can get_all_attributes' ); + my (@attributes) = Example_2->meta->get_all_attributes; + is( scalar @attributes, 1, 'Has one attribute' ); +}; + +ok( Example_3->can('meta'), 'Example_3 can meta') and subtest meta_checks_for_Example_3 => sub { + return unless is( exception { Example_3->meta->can('can') } , undef, "Example_3->meta->can doesn't explode" ); + return unless ok( Example_3->meta->can('get_all_attributes'), 'Example_3 meta can get_all_attributes' ); + my (@attributes) = Example_3->meta->get_all_attributes; + is( scalar @attributes, 1, 'Has one attribute' ); +}; + +done_testing;