4 use Test::More tests => 9;
14 default => sub { [1] },
21 default => sub { sub { 1 } },
30 } qr/References are not allowed as default values/;
37 } qr/References are not allowed as default values/;
42 default => Test::Builder->new,
44 } qr/References are not allowed as default values/;
47 is(ref(Class->new->code), 'CODE', "default => sub { sub { 1 } } stuffs a coderef");
48 is(Class->new->code->(), 1, "default => sub sub strips off the first coderef");
49 is_deeply(Class->new->a, [1], "default of sub { reference } works");
54 has foo => (is => 'rw', default => sub {
55 die unless $_[0]->isa('Class::Two');
58 sub default_foo { 1 };
61 my $obj2 = Class::Two->new;
62 is($obj2->foo, 1, 'default method gets the $_[0] it needs to work');