From: Toby Inkster Date: Fri, 15 Feb 2013 11:55:04 +0000 (+0000) Subject: fix test case that relies on a misfeature X-Git-Tag: v1.001000~7 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=b9d02f453b0c2a1a919a235c662850cec770d092;p=gitmo%2FMoo.git fix test case that relies on a misfeature --- diff --git a/t/method-generate-accessor.t b/t/method-generate-accessor.t index 6da7e99..3229052 100644 --- a/t/method-generate-accessor.t +++ b/t/method-generate-accessor.t @@ -37,40 +37,45 @@ like( qr/Invalid coerce/, "coerce - scalar rejected" ); +for my $setting (qw( default coerce )) { + like( + exception { $gen->generate_method('Foo' => 'four' => { allow_overwrite => 1, is => 'ro', $setting => 5 }) }, + qr/Invalid $setting/, "$setting - scalar rejected" + ); + is( exception { $gen->generate_method('Foo' => 'four' => { is => 'ro', default => 5 }) }, undef, "default - non-ref scalar accepted" ); - for my $setting (qw( default coerce )) { like( - exception { $gen->generate_method('Foo' => 'five' => { is => 'ro', $setting => [] }) }, + exception { $gen->generate_method('Foo' => 'five' => { allow_overwrite => 1, is => 'ro', $setting => [] }) }, qr/Invalid $setting/, "$setting - arrayref rejected" ); like( - exception { $gen->generate_method('Foo' => 'five' => { is => 'ro', $setting => Foo->new }) }, + exception { $gen->generate_method('Foo' => 'five' => { allow_overwrite => 1, is => 'ro', $setting => Foo->new }) }, qr/Invalid $setting/, "$setting - non-code-convertible object rejected" ); is( - exception { $gen->generate_method('Foo' => 'six' => { is => 'ro', $setting => sub { 5 } }) }, + exception { $gen->generate_method('Foo' => 'six' => { allow_overwrite => 1, is => 'ro', $setting => sub { 5 } }) }, undef, "$setting - coderef accepted" ); is( - exception { $gen->generate_method('Foo' => 'seven' => { is => 'ro', $setting => bless sub { 5 } => 'Blah' }) }, + exception { $gen->generate_method('Foo' => 'seven' => { allow_overwrite => 1, is => 'ro', $setting => bless sub { 5 } => 'Blah' }) }, undef, "$setting - blessed sub accepted" ); is( - exception { $gen->generate_method('Foo' => 'eight' => { is => 'ro', $setting => WithOverload->new }) }, + exception { $gen->generate_method('Foo' => 'eight' => { allow_overwrite => 1, is => 'ro', $setting => WithOverload->new }) }, undef, "$setting - object with overloaded ->() accepted" ); like( - exception { $gen->generate_method('Foo' => 'nine' => { is => 'ro', $setting => bless {} => 'Blah' }) }, + exception { $gen->generate_method('Foo' => 'nine' => { allow_overwrite => 1, is => 'ro', $setting => bless {} => 'Blah' }) }, qr/Invalid $setting/, "$setting - object rejected" ); }