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"
);
}