From: gfx Date: Fri, 26 Feb 2010 06:01:31 +0000 (+0900) Subject: More tests for strict constructor X-Git-Tag: 0.50_04~13 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=81c629ebda18684a5bc69906308113423a7a58b4;p=gitmo%2FMouse.git More tests for strict constructor --- 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;