Commit | Line | Data |
fc1d8369 |
1 | #!/usr/bin/perl |
fde8e43f |
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; |
fc1d8369 |
5 | |
6 | use strict; |
7 | use warnings; |
8 | |
fde8e43f |
9 | use Test::More; |
10 | $TODO = q{Mouse is not yet completed}; |
fc1d8369 |
11 | use Test::Exception; |
12 | |
13 | use Mouse::Meta::Role; |
14 | |
15 | |
16 | { |
17 | package FooRole; |
18 | our $VERSION = '0.01'; |
19 | sub foo {'FooRole::foo'} |
20 | } |
21 | |
22 | { |
23 | package Foo; |
24 | use Mouse; |
25 | |
26 | #two checks because the inlined methods are different when |
27 | #there is a TC present. |
28 | has 'foos' => ( is => 'ro', lazy_build => 1 ); |
29 | has 'bars' => ( isa => 'Str', is => 'ro', lazy_build => 1 ); |
30 | has 'bazes' => ( isa => 'Str', is => 'ro', builder => '_build_bazes' ); |
31 | sub _build_foos {"many foos"} |
32 | sub _build_bars {"many bars"} |
33 | sub _build_bazes {"many bazes"} |
34 | } |
35 | |
36 | { |
37 | my $foo_role = Mouse::Meta::Role->initialize('FooRole'); |
38 | my $meta = Foo->meta; |
39 | |
40 | lives_ok { Foo->new } "lazy_build works"; |
41 | is( Foo->new->foos, 'many foos', |
42 | "correct value for 'foos' before inlining constructor" ); |
43 | is( Foo->new->bars, 'many bars', |
44 | "correct value for 'bars' before inlining constructor" ); |
45 | is( Foo->new->bazes, 'many bazes', |
46 | "correct value for 'bazes' before inlining constructor" ); |
47 | lives_ok { $meta->make_immutable } "Foo is imutable"; |
7ca5c5fb |
48 | lives_ok { $meta->identifier } "->identifier on metaclass lives"; |
49 | dies_ok { $meta->add_role($foo_role) } "Add Role is locked"; |
fc1d8369 |
50 | lives_ok { Foo->new } "Inlined constructor works with lazy_build"; |
51 | is( Foo->new->foos, 'many foos', |
52 | "correct value for 'foos' after inlining constructor" ); |
53 | is( Foo->new->bars, 'many bars', |
54 | "correct value for 'bars' after inlining constructor" ); |
55 | is( Foo->new->bazes, 'many bazes', |
56 | "correct value for 'bazes' after inlining constructor" ); |
fde8e43f |
57 | lives_ok { $meta->make_mutable } "Foo is mutable"; |
58 | lives_ok { $meta->add_role($foo_role) } "Add Role is unlocked"; |
fc1d8369 |
59 | |
60 | } |
61 | |
62 | { |
63 | package Bar; |
64 | |
65 | use Mouse; |
66 | |
67 | sub BUILD { 'bar' } |
68 | } |
69 | |
70 | { |
71 | package Baz; |
72 | |
73 | use Mouse; |
74 | |
75 | extends 'Bar'; |
76 | |
77 | sub BUILD { 'baz' } |
78 | } |
79 | |
80 | lives_ok { Bar->meta->make_immutable } |
81 | 'Immutable meta with single BUILD'; |
82 | |
83 | lives_ok { Baz->meta->make_immutable } |
84 | 'Immutable meta with multiple BUILDs'; |
85 | |
86 | =pod |
87 | |
88 | Nothing here yet, but soon :) |
89 | |
90 | =cut |
fde8e43f |
91 | |
92 | done_testing; |