diff options
author | Jesse Luehrs <doy@tozt.net> | 2009-07-10 20:21:22 -0500 |
---|---|---|
committer | Jesse Luehrs <doy@tozt.net> | 2009-07-10 20:21:22 -0500 |
commit | 68812549c073b87fbdf9849cf8e455479978fab0 (patch) | |
tree | 92973386d04203f2234b4613332b56735c6b0451 | |
parent | 3f55f52f06630ea8c2d60e678b67bbbb91e0e1d2 (diff) | |
download | moosex-abc-68812549c073b87fbdf9849cf8e455479978fab0.tar.gz moosex-abc-68812549c073b87fbdf9849cf8e455479978fab0.zip |
add a few more tests for multi-level inheritance
-rw-r--r-- | t/001-basic.t | 11 | ||||
-rw-r--r-- | t/002-immutable.t | 11 |
2 files changed, 20 insertions, 2 deletions
diff --git a/t/001-basic.t b/t/001-basic.t index 44a68dd..d5951d4 100644 --- a/t/001-basic.t +++ b/t/001-basic.t @@ -1,7 +1,7 @@ #!/usr/bin/env perl use strict; use warnings; -use Test::More tests => 5; +use Test::More tests => 9; use Test::Exception; package Foo; @@ -22,10 +22,19 @@ use Moose; 'extending fails with the correct error when requires are not fulfilled'; sub bar { } +package Foo::Sub::Sub; +use Moose; +::lives_ok { extends 'Foo::Sub1' } 'extending twice works'; + package main; my $foosub; lives_ok { $foosub = Foo::Sub1->new } 'instantiating concrete subclasses works'; isa_ok($foosub, 'Foo', 'inheritance is correct'); +my $foosubsub; +lives_ok { $foosubsub = Foo::Sub::Sub->new } + 'instantiating deeper concrete subclasses works'; +isa_ok($foosubsub, 'Foo', 'inheritance is correct'); +isa_ok($foosubsub, 'Foo::Sub1', 'inheritance is correct'); throws_ok { Foo->new } qr/Foo is abstract, it cannot be instantiated/, 'instantiating abstract classes fails'; diff --git a/t/002-immutable.t b/t/002-immutable.t index 0f4bce8..66424da 100644 --- a/t/002-immutable.t +++ b/t/002-immutable.t @@ -1,7 +1,7 @@ #!/usr/bin/env perl use strict; use warnings; -use Test::More tests => 5; +use Test::More tests => 9; use Test::Exception; package Foo; @@ -26,6 +26,10 @@ use Moose; 'extending fails with the correct error when requires are not fulfilled'; sub bar { } +package Foo::Sub::Sub; +use Moose; +::lives_ok { extends 'Foo::Sub1' } 'extending twice works'; + __PACKAGE__->meta->make_immutable; package main; @@ -33,5 +37,10 @@ my $foosub; lives_ok { $foosub = Foo::Sub1->new } 'instantiating concrete subclasses works'; isa_ok($foosub, 'Foo', 'inheritance is correct'); +my $foosubsub; +lives_ok { $foosubsub = Foo::Sub::Sub->new } + 'instantiating deeper concrete subclasses works'; +isa_ok($foosubsub, 'Foo', 'inheritance is correct'); +isa_ok($foosubsub, 'Foo::Sub1', 'inheritance is correct'); throws_ok { Foo->new } qr/Foo is abstract, it cannot be instantiated/, 'instantiating abstract classes fails'; |