From b65a6c14ae6ec7e4b8ca7de7c7bcb02334bbec1c Mon Sep 17 00:00:00 2001 From: gfx Date: Tue, 6 Jul 2010 20:24:09 +0900 Subject: [PATCH] Test for subclassing --- t/001_basic.t | 34 ++++++++++++++++++++++++++++------ 1 file changed, 28 insertions(+), 6 deletions(-) diff --git a/t/001_basic.t b/t/001_basic.t index a18ef2b..e23c006 100755 --- a/t/001_basic.t +++ b/t/001_basic.t @@ -1,6 +1,8 @@ #!perl -w use Test::More; +use Test::Mouse; + { package Foo; use Mouse; @@ -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;