+ - isa checks on builders
- additional quote_sub docs
- remove multi-populate code to fix exists/defined new() bug
- document move to #moose and include repository metadata
'do { '.$self->_generate_use_default(
'$_[0]', $name, $spec,
$self->_generate_simple_has('$_[0]', $name, $spec),
- ).'; '.$simple.' }';
+ ).'; '
+ .($spec->{isa}
+ ?($self->_generate_isa_check($name, $simple, $spec->{isa}).'; ')
+ :''
+ )
+ .$simple.' }';
}
}
run_for 'Baz';
+{
+ package LazyFoo;
+
+ use Moo;
+
+ has less_than_three => (
+ is => 'lazy',
+ isa => sub { die "$_[0] is not less than three" unless $_[0] < 3 }
+ );
+
+ sub _build_less_than_three { 4 }
+}
+
+like(
+ exception { LazyFoo->new->less_than_three },
+ qr/4 is not less than three/,
+ "exception thrown on bad builder return value (LazyFoo)"
+);
+
done_testing;