From: Shawn M Moore Date: Sat, 4 Aug 2007 19:02:31 +0000 (+0000) Subject: Add mysteriously-missing Bool handling X-Git-Tag: 0_07~7 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=d691721b11887b3ce12fbf5e4b854bf292033a4e;p=gitmo%2FMooseX-Storage.git Add mysteriously-missing Bool handling --- diff --git a/lib/MooseX/Storage/Engine.pm b/lib/MooseX/Storage/Engine.pm index 7a266dd..07aeae2 100644 --- a/lib/MooseX/Storage/Engine.pm +++ b/lib/MooseX/Storage/Engine.pm @@ -204,6 +204,7 @@ my %TYPES = ( 'Int' => { expand => sub { shift }, collapse => sub { shift } }, 'Num' => { expand => sub { shift }, collapse => sub { shift } }, 'Str' => { expand => sub { shift }, collapse => sub { shift } }, + 'Bool' => { expand => sub { shift }, collapse => sub { shift } }, # These are the trickier ones, (see notes) # NOTE: # Because we are nice guys, we will check diff --git a/t/001_basic.t b/t/001_basic.t index 91848c2..fcb591a 100644 --- a/t/001_basic.t +++ b/t/001_basic.t @@ -3,7 +3,7 @@ use strict; use warnings; -use Test::More tests => 11; +use Test::More tests => 12; BEGIN { use_ok('MooseX::Storage'); @@ -17,22 +17,24 @@ BEGIN { with Storage; - has 'number' => ( is => 'ro', isa => 'Int' ); - has 'string' => ( is => 'ro', isa => 'Str' ); - has 'float' => ( is => 'ro', isa => 'Num' ); - has 'array' => ( is => 'ro', isa => 'ArrayRef' ); - has 'hash' => ( is => 'ro', isa => 'HashRef' ); - has 'object' => ( is => 'ro', isa => 'Foo' ); + has 'number' => ( is => 'ro', isa => 'Int' ); + has 'string' => ( is => 'ro', isa => 'Str' ); + has 'boolean' => ( is => 'ro', isa => 'Bool' ); + has 'float' => ( is => 'ro', isa => 'Num' ); + has 'array' => ( is => 'ro', isa => 'ArrayRef' ); + has 'hash' => ( is => 'ro', isa => 'HashRef' ); + has 'object' => ( is => 'ro', isa => 'Foo' ); } { my $foo = Foo->new( - number => 10, - string => 'foo', - float => 10.5, - array => [ 1 .. 10 ], - hash => { map { $_ => undef } ( 1 .. 10 ) }, - object => Foo->new( number => 2 ), + number => 10, + string => 'foo', + boolean => 1, + float => 10.5, + array => [ 1 .. 10 ], + hash => { map { $_ => undef } ( 1 .. 10 ) }, + object => Foo->new( number => 2 ), ); isa_ok( $foo, 'Foo' ); @@ -42,6 +44,7 @@ BEGIN { __CLASS__ => 'Foo', number => 10, string => 'foo', + boolean => 1, float => 10.5, array => [ 1 .. 10 ], hash => { map { $_ => undef } ( 1 .. 10 ) }, @@ -60,6 +63,7 @@ BEGIN { __CLASS__ => 'Foo', number => 10, string => 'foo', + boolean => 1, float => 10.5, array => [ 1 .. 10 ], hash => { map { $_ => undef } ( 1 .. 10 ) }, @@ -73,6 +77,7 @@ BEGIN { is( $foo->number, 10, '... got the right number' ); is( $foo->string, 'foo', '... got the right string' ); + ok( $foo->boolean, '... got the right boolean' ); is( $foo->float, 10.5, '... got the right float' ); is_deeply( $foo->array, [ 1 .. 10 ], '... got the right array' ); is_deeply(