X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=gitmo%2FMooseX-Singleton.git;a=blobdiff_plain;f=t%2F003-immutable.t;h=05ff974ea5d1a0f41e40f6f88c3931e310ec4d1a;hp=1385d0727bbf47a8779bb2a8a1951187c0f3e6d7;hb=4c25692312665e52f72b16a0a3086046590cf46a;hpb=2cb90d536c9fe23d25b545966ce509e7da73fa68 diff --git a/t/003-immutable.t b/t/003-immutable.t index 1385d07..05ff974 100644 --- a/t/003-immutable.t +++ b/t/003-immutable.t @@ -5,7 +5,7 @@ use Scalar::Util qw( refaddr ); use Test::More; BEGIN { - unless ( eval 'use Test::Warn; 1' ) { + unless ( eval 'use Test::Warn; 1' ) { plan skip_all => 'These tests require Test::Warn'; } else { @@ -30,12 +30,12 @@ BEGIN { sub clear { my $self = shift; - $self->bag({}); + $self->bag( {} ); } sub add { - my $self = shift; - my $key = shift; + my $self = shift; + my $key = shift; my $value = @_ ? shift : 1; $self->bag->{$key} += $value; @@ -46,40 +46,42 @@ BEGIN { } my $mst = MooseX::Singleton::Test->instance; -isa_ok($mst, 'MooseX::Singleton::Test', 'Singleton->instance returns a real instance'); +isa_ok( $mst, 'MooseX::Singleton::Test', + 'Singleton->instance returns a real instance' ); -is($mst->distinct_keys, 1, "default keys"); +is( $mst->distinct_keys, 1, "default keys" ); -$mst->add(foo => 10); -is($mst->distinct_keys, 2, "added key"); +$mst->add( foo => 10 ); +is( $mst->distinct_keys, 2, "added key" ); -$mst->add(bar => 5); -is($mst->distinct_keys, 3, "added another key"); +$mst->add( bar => 5 ); +is( $mst->distinct_keys, 3, "added another key" ); my $mst2 = MooseX::Singleton::Test->instance; -is($mst, $mst2, 'instances are the same object'); -isa_ok($mst2, 'MooseX::Singleton::Test', 'Singleton->instance returns a real instance'); +is( $mst, $mst2, 'instances are the same object' ); +isa_ok( $mst2, 'MooseX::Singleton::Test', + 'Singleton->instance returns a real instance' ); -is($mst2->distinct_keys, 3, "keys from before"); +is( $mst2->distinct_keys, 3, "keys from before" ); -$mst->add(baz => 2); +$mst->add( baz => 2 ); -is($mst->distinct_keys, 4, "attributes are shared even after ->instance"); -is($mst2->distinct_keys, 4, "attributes are shared even after ->instance"); +is( $mst->distinct_keys, 4, "attributes are shared even after ->instance" ); +is( $mst2->distinct_keys, 4, "attributes are shared even after ->instance" ); -is(MooseX::Singleton::Test->distinct_keys, 4, "Package->reader works"); +is( MooseX::Singleton::Test->distinct_keys, 4, "Package->reader works" ); -MooseX::Singleton::Test->add(quux => 9000); +MooseX::Singleton::Test->add( quux => 9000 ); -is($mst->distinct_keys, 5, "Package->add works"); -is($mst2->distinct_keys, 5, "Package->add works"); -is(MooseX::Singleton::Test->distinct_keys, 5, "Package->add works"); +is( $mst->distinct_keys, 5, "Package->add works" ); +is( $mst2->distinct_keys, 5, "Package->add works" ); +is( MooseX::Singleton::Test->distinct_keys, 5, "Package->add works" ); MooseX::Singleton::Test->clear; -is($mst->distinct_keys, 0, "Package->clear works"); -is($mst2->distinct_keys, 0, "Package->clear works"); -is(MooseX::Singleton::Test->distinct_keys, 0, "Package->clear works"); +is( $mst->distinct_keys, 0, "Package->clear works" ); +is( $mst2->distinct_keys, 0, "Package->clear works" ); +is( MooseX::Singleton::Test->distinct_keys, 0, "Package->clear works" ); { my $addr; @@ -88,7 +90,8 @@ is(MooseX::Singleton::Test->distinct_keys, 0, "Package->clear works"); $addr = refaddr( MooseX::Singleton::Test->instance ); } - is( $addr, refaddr( MooseX::Singleton::Test->instance ), - 'singleton is not randomly destroyed' ); + is( + $addr, refaddr( MooseX::Singleton::Test->instance ), + 'singleton is not randomly destroyed' + ); } -