Commit | Line | Data |
e2119ce9 |
1 | use strict; |
2 | use warnings; |
3 | |
4 | use Test::More 'no_plan'; |
5 | |
6 | { |
7 | package MySingleton; |
8 | use MooseX::Singleton; |
9 | |
10 | has 'attrib' => |
11 | is => 'rw', |
12 | isa => 'Str', |
13 | default => 'foo'; |
14 | |
15 | sub hello {'world'} |
16 | |
17 | sub BUILDARGS { |
18 | my ( $class, %opts ) = @_; |
19 | |
20 | { attrib => 'bar', %opts }; |
21 | } |
22 | } |
23 | |
24 | is( |
25 | MySingleton->attrib, 'bar', |
26 | 'BUILDARGS changed value of attrib when instance was auto-instantiated' |
27 | ); |
28 | |
29 | MySingleton->meta->remove_package_glob('singleton'); |
30 | |
31 | MySingleton->instance; |
32 | |
33 | is( |
34 | MySingleton->attrib, 'bar', |
35 | 'BUILDARGS changed value of attrib when instance was explicitly instantiated' |
36 | ); |