Commit | Line | Data |
---|---|---|
14676933 | 1 | use Test::More tests => 4; |
443f4253 | 2 | |
3 | use strict; | |
4 | use warnings; | |
5 | ||
6 | { | |
14676933 | 7 | package Foo::Singleton; |
8 | use Moose; | |
443f4253 | 9 | |
14676933 | 10 | with qw/MooseX::Singleton/; |
443f4253 | 11 | |
14676933 | 12 | has gravy => (is => 'rw'); |
443f4253 | 13 | } |
14 | ||
14676933 | 15 | my $ante = Foo::Singleton->instance; |
443f4253 | 16 | |
14676933 | 17 | ok(Foo::Singleton->new,'new'); |
443f4253 | 18 | |
14676933 | 19 | my $foo = Foo::Singleton->instance; |
443f4253 | 20 | my $bar = Foo::Singleton->instance; |
14676933 | 21 | my $baz = Foo::Singleton->new; |
443f4253 | 22 | |
14676933 | 23 | $foo->gravy('sauce'); |
443f4253 | 24 | |
14676933 | 25 | is($bar->gravy,'sauce','singleton'); |
26 | is($baz->gravy,'sauce','singleton'); | |
27 | is($ante->gravy,'sauce','singleton'); | |
443f4253 | 28 |