Mouse::Util::does_role() respects $thing->does() method
[gitmo/Mouse.git] / t / 300_immutable / 016_inline_fallbacks.t
1 use strict;
2 # This is automatically generated by author/import-moose-test.pl.
3 # DO NOT EDIT THIS FILE. ANY CHANGES WILL BE LOST!!!
4 use t::lib::MooseCompat;
5 use warnings;
6 use Test::More;
7
8 {
9     package Foo;
10     use Mouse;
11     has foo => (is => 'ro');
12 }
13
14 {
15     package Foo::Sub;
16     use Mouse;
17     extends 'Foo';
18     has bar => (is => 'ro');
19 }
20
21 {
22     my $foo = Foo::Sub->new(foo => 12, bar => 25);
23     is($foo->foo, 12, 'got right value for foo');
24     is($foo->bar, 25, 'got right value for bar');
25 }
26
27 Foo->meta->make_immutable;
28
29 {
30     package Foo::Sub2;
31     use Mouse;
32     extends 'Foo';
33     has baz => (is => 'ro');
34     # not making immutable, inheriting Foo's inlined constructor
35 }
36
37 {
38     my $foo = Foo::Sub2->new(foo => 42, baz => 27);
39     is($foo->foo, 42, 'got right value for foo');
40     is($foo->baz, 27, 'got right value for baz');
41 }
42
43 my $BAR = 0;
44 {
45     package Bar;
46     use Mouse;
47 }
48
49 {
50     package Bar::Sub;
51     use Mouse;
52     extends 'Bar';
53     sub DEMOLISH { $BAR++ }
54 }
55
56 Bar::Sub->new;
57 is($BAR, 1, 'DEMOLISH in subclass was called');
58 $BAR = 0;
59
60 Bar->meta->make_immutable;
61
62 {
63     package Bar::Sub2;
64     use Mouse;
65     extends 'Bar';
66     sub DEMOLISH { $BAR++ }
67     # not making immutable, inheriting Bar's inlined destructor
68 }
69
70 Bar::Sub2->new;
71 is($BAR, 1, 'DEMOLISH in subclass was called');
72
73 done_testing;