- - throw an error on non-string builder (RT#78479)
+ - throw an error on invalid builder (RT#78479)
- require D::GD 0.07 to avoid prototype mismatch errors
- fix stupid typo in new Sub::Quote section
die "Unknown is ${is}";
}
$spec->{builder} = '_build_'.$name if ($spec->{builder}||0) eq 1;
- die "Invalid builder for $into->$name - not a string"
- if exists $spec->{builder} and ref $spec->{builder};
+ die "Invalid builder for $into->$name - not a valid method name"
+ if exists $spec->{builder} and (ref $spec->{builder}
+ or $spec->{builder} !~ /\A[A-Za-z_][A-Za-z0-9_]*(?:::[A-Za-z_][A-Za-z0-9_]*)*\z/);
if (($spec->{predicate}||0) eq 1) {
$spec->{predicate} = $name =~ /^_/ ? "_has${name}" : "has_${name}";
}
qr/Invalid builder/, 'builder - coderef rejected'
);
+like(
+ exception { $gen->generate_method('Foo' => 'twelve' => { is => 'ro', builder => 'build:twelve' }) },
+ qr/Invalid builder/, 'builder - invalid name rejected',
+);
+
+is(
+ exception { $gen->generate_method('Foo' => 'thirteen' => { is => 'ro', builder => 'build::thirteen' }) },
+ undef, 'builder - fully-qualified name accepted',
+);
+
my $foo = Foo->new(one => 1);
is($foo->one, 1, 'ro reads');