6 use Scalar::Util 'blessed';
7 use Benchmark qw[cmpthese];
9 use Moose::Util::TypeConstraints;
12 subtype 'Foo' => as 'Object' => where { blessed($_) && $_->isa('Foo') };
16 => via { Foo->new(@{$_}) };
28 has 'default' => (is => 'rw', default => 10);
29 has 'default_sub' => (is => 'rw', default => sub { [] });
30 has 'lazy' => (is => 'rw', default => 10, lazy => 1);
31 has 'required' => (is => 'rw', required => 1);
32 has 'weak_ref' => (is => 'rw', weak_ref => 1);
33 has 'type_constraint' => (is => 'rw', isa => 'Foo');
34 has 'coercion' => (is => 'rw', isa => 'Foo', coerce => 1);
39 package Foo::Immutable;
42 has 'default' => (is => 'rw', default => 10);
43 has 'default_sub' => (is => 'rw', default => sub { [] });
44 has 'lazy' => (is => 'rw', default => 10, lazy => 1);
45 has 'required' => (is => 'rw', required => 1);
46 has 'weak_ref' => (is => 'rw', weak_ref => 1);
47 has 'type_constraint' => (is => 'rw', isa => 'Foo');
48 has 'coercion' => (is => 'rw', isa => 'Foo', coerce => 1);
54 Foo::Immutable->meta->make_immutable(debug => 1);
66 type_constraint => $foo,
73 type_constraint => $foo,