Skip to content

Commit

Permalink
Test for subclassing
Browse files Browse the repository at this point in the history
  • Loading branch information
gfx committed Jul 6, 2010
1 parent eb4de68 commit b65a6c1
Showing 1 changed file with 28 additions and 6 deletions.
34 changes: 28 additions & 6 deletions t/001_basic.t
@@ -1,6 +1,8 @@
#!perl -w
use Test::More;

use Test::Mouse;

{
package Foo;
use Mouse;
Expand All @@ -9,12 +11,32 @@ use Test::More;
has [qw(foo bar)] => (is => 'rw');
}

isa_ok(Foo->new(foo => 1, bar => 2), 'Foo');
{
package Foo::Bar;
use Mouse;
extends 'Foo';

has [qw(baz)] => (is => 'rw');
}

with_immutable sub {
isa_ok(Foo->new(foo => 1, bar => 2), 'Foo');

eval {
Foo->new(foo => 1, bar => 2, baz => 3);
};
like $@, qr/\b Foo \b/xms;
like $@, qr/\b baz \b/xms;

isa_ok eval {
Foo::Bar->new(foo => 1, bar => 2, baz => 3);
}, 'Foo::Bar';

eval {
Foo->new(foo => 1, bar => 2, baz => 3);
};
like $@, qr/\b Foo \b/xms;
like $@, qr/\b baz \b/xms;
eval {
Foo::Bar->new(foo => 1, bar => 2, baz => 3, qux => 4);
};
like $@, qr/\b Foo::Bar \b/xms;
like $@, qr/\b qux \b/xms;
}, qw(Foo Foo::Bar);

done_testing;

0 comments on commit b65a6c1

Please sign in to comment.