X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=gitmo%2FMouse.git;a=blobdiff_plain;f=t%2F001_mouse%2F068-strict-constructor.t;h=cd38d21b8e85f37c791ed44848db6afc9b042273;hp=d95e07fe2bf492cdc7a213b6f8a599a7525d319a;hb=81c629ebda18684a5bc69906308113423a7a58b4;hpb=7fc1f782a03cad730507528abb9707a107b8eba8 diff --git a/t/001_mouse/068-strict-constructor.t b/t/001_mouse/068-strict-constructor.t index d95e07f..cd38d21 100644 --- a/t/001_mouse/068-strict-constructor.t +++ b/t/001_mouse/068-strict-constructor.t @@ -20,12 +20,26 @@ use Test::Exception; init_arg => undef, ); + has baz => ( + is => 'rw', + default => 42, + ); + __PACKAGE__->meta->make_immutable(strict_constructor => 1); } -lives_ok { - MyClass->new(foo => 1); -}; +lives_and { + my $o = MyClass->new(foo => 1); + isa_ok($o, 'MyClass'); + is $o->baz, 42; +} 'correc use of the constructor'; + +lives_and { + my $o = MyClass->new(foo => 1, baz => 10); + isa_ok($o, 'MyClass'); + is $o->baz, 10; +} 'correc use of the constructor'; + throws_ok { MyClass->new(foo => 1, hoge => 42); @@ -38,14 +52,14 @@ throws_ok { throws_ok { MyClass->new(aaa => 1, bbb => 2, ccc => 3); -} qr/\b aaa \b/xms; +} qr/\b aaa \b/xms, $@; throws_ok { MyClass->new(aaa => 1, bbb => 2, ccc => 3); -} qr/\b bbb \b/xms; +} qr/\b bbb \b/xms, $@; throws_ok { MyClass->new(aaa => 1, bbb => 2, ccc => 3); -} qr/\b ccc \b/xms; +} qr/\b ccc \b/xms, $@; done_testing;