X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=t%2F201-squirrel.t;h=daeed221d206528bb7cd0b19052e52f9aa89923a;hb=a497c7d3c518bbecf930e3f17d7a75b9bf84fa2f;hp=aa09a9d9536b7efb98a52033c07ab608063225d9;hpb=303b7f48e732f24efaf609b899c317506c59bbdb;p=gitmo%2FMouse.git diff --git a/t/201-squirrel.t b/t/201-squirrel.t index aa09a9d..daeed22 100644 --- a/t/201-squirrel.t +++ b/t/201-squirrel.t @@ -4,8 +4,14 @@ use strict; use warnings; use Test::More; +use Scalar::Util 'blessed'; -{ +# Don't spew deprecation warnings onto the user's screen +BEGIN { + $SIG{__WARN__} = sub { warn $_[0] if $_[0] !~ /Squirrel is deprecated/ }; +} + +do { package Foo; use Squirrel; @@ -13,17 +19,19 @@ use Test::More; isa => "Int", is => "rw", ); -} + + no Squirrel; +}; # note that 'Foo' is defined before this, to prevent Moose being loaded from # affecting its definition BEGIN { - plan skip_all => "Moose required for this test" unless eval { require Moose }; - plan 'no_plan'; + plan skip_all => "Moose 0.68 required for this test" unless eval { require Moose && Moose->VERSION('0.68') }; + plan tests => 12; } -{ +do { package Bar; use Squirrel; @@ -31,20 +39,41 @@ BEGIN { isa => "Int", is => "rw", ); -} -my $foo = Foo->new( foo => 3 ); + no Squirrel; +}; + +my $foo = Foo->new(foo => 3); +isa_ok($foo, "Foo"); +isa_ok($foo, "Mouse::Object"); +is($foo->foo, 3, "accessor"); -isa_ok( $foo, "Foo" ); +my $bar = Bar->new(foo => 3); +isa_ok($bar, "Bar"); +isa_ok($bar, "Moose::Object"); +is($bar->foo, 3, "accessor"); -isa_ok( $foo, "Mouse::Object" ); +ok(!Foo->can('has'), "Mouse::has was unimported"); +ok(!Bar->can('has'), "Moose::has was unimported"); -is( $foo->foo, 3, "accessor" ); +eval " + package Foo; + use Squirrel; + + has bar => (is => 'rw'); + __PACKAGE__->meta->make_immutable; + + package Bar; + use Squirrel; + has bar => (is => 'rw'); + __PACKAGE__->meta->make_immutable; +"; +warn $@ if $@; -my $bar = Bar->new( foo => 3 ); +is(blessed(Foo->meta->get_attribute('foo')), 'Mouse::Meta::Attribute'); +is(blessed(Foo->meta->get_attribute('bar')), 'Mouse::Meta::Attribute', 'Squirrel is consistent if Moose was loaded between imports'); -isa_ok( $bar, "Bar" ); -isa_ok( $bar, "Moose::Object" ); +is(blessed(Bar->meta->get_attribute('foo')), 'Moose::Meta::Attribute'); +is(blessed(Bar->meta->get_attribute('bar')), 'Moose::Meta::Attribute'); -is( $bar->foo, 3, "accessor" );