Mouse::Util::does_role() respects $thing->does() method
[gitmo/Mouse.git] / t / 900_mouse_bugs / 006_RT69939.t
1 #!perl -w
2
3 use Test::More;
4
5 BEGIN {
6     if($^O =~ /bsd/) {
7         plan skip_all => q{TODO: *bsd might fail on this tests (this test is an workaround to a core bug)};
8     }
9 }
10
11 package Foo;
12 use Mouse;
13
14 has bar => (
15     is => 'rw',
16
17     trigger => sub {
18         eval 'BEGIN{ die }';
19     },
20     default => sub {
21         eval 'BEGIN{ die }';
22         return 42;
23     },
24 );
25
26 sub BUILDARGS {
27     eval 'BEGIN{ die }';
28     return {};
29 }
30
31 sub BUILD {
32     eval 'BEGIN{ die }';
33 }
34
35 package main;
36
37 use Test::More tests => 3 * 3;
38
39 $@ = '(ERRSV)';
40
41 note 'do {}';
42 do {
43     my $foo = Foo->new;
44     isa_ok $foo, 'Foo';
45     is $foo->bar, 42;
46     $foo->bar(100);
47     is $foo->bar, 100;
48     note("\$@=$@");
49 };
50
51 note 'eval {}';
52 eval {
53     my $foo = Foo->new;
54     isa_ok $foo, 'Foo';
55     is $foo->bar, 42;
56     $foo->bar(100);
57     is $foo->bar, 100;
58     note("\$@=$@");
59 };
60
61 note 'eval ""';
62 eval q{
63     my $foo = Foo->new;
64     isa_ok $foo, 'Foo';
65     is $foo->bar, 42;
66     $foo->bar(100);
67     is $foo->bar, 100;
68     note("\$@=$@");
69 };