From: Karen Etheridge Date: Thu, 20 Jun 2013 19:11:08 +0000 (-0700) Subject: remove whitespace X-Git-Tag: 0.34~5 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=gitmo%2FMooseX-Storage.git;a=commitdiff_plain;h=c2dae5d88280be6f80857e79194f092298f88b36 remove whitespace --- diff --git a/lib/MooseX/Storage/Engine.pm b/lib/MooseX/Storage/Engine.pm index c7bea10..bf64033 100644 --- a/lib/MooseX/Storage/Engine.pm +++ b/lib/MooseX/Storage/Engine.pm @@ -1,4 +1,3 @@ - package MooseX::Storage::Engine; use Moose; use Scalar::Util qw(refaddr); diff --git a/lib/MooseX/Storage/Engine/IO/AtomicFile.pm b/lib/MooseX/Storage/Engine/IO/AtomicFile.pm index 80e51a0..c0d370b 100644 --- a/lib/MooseX/Storage/Engine/IO/AtomicFile.pm +++ b/lib/MooseX/Storage/Engine/IO/AtomicFile.pm @@ -1,4 +1,3 @@ - package MooseX::Storage::Engine::IO::AtomicFile; use Moose; diff --git a/lib/MooseX/Storage/Engine/IO/File.pm b/lib/MooseX/Storage/Engine/IO/File.pm index 6458094..aae71a7 100644 --- a/lib/MooseX/Storage/Engine/IO/File.pm +++ b/lib/MooseX/Storage/Engine/IO/File.pm @@ -1,4 +1,3 @@ - package MooseX::Storage::Engine::IO::File; use Moose; diff --git a/lib/MooseX/Storage/Format/JSON.pm b/lib/MooseX/Storage/Format/JSON.pm index 1d3a6c6..378be75 100644 --- a/lib/MooseX/Storage/Format/JSON.pm +++ b/lib/MooseX/Storage/Format/JSON.pm @@ -1,4 +1,3 @@ - package MooseX::Storage::Format::JSON; use Moose::Role; diff --git a/lib/MooseX/Storage/Format/Storable.pm b/lib/MooseX/Storage/Format/Storable.pm index fb08c04..24c077f 100644 --- a/lib/MooseX/Storage/Format/Storable.pm +++ b/lib/MooseX/Storage/Format/Storable.pm @@ -1,4 +1,3 @@ - package MooseX::Storage::Format::Storable; use Moose::Role; diff --git a/lib/MooseX/Storage/Meta/Attribute/DoNotSerialize.pm b/lib/MooseX/Storage/Meta/Attribute/DoNotSerialize.pm index b739042..87ef7ed 100644 --- a/lib/MooseX/Storage/Meta/Attribute/DoNotSerialize.pm +++ b/lib/MooseX/Storage/Meta/Attribute/DoNotSerialize.pm @@ -1,4 +1,3 @@ - package MooseX::Storage::Meta::Attribute::DoNotSerialize; use Moose; diff --git a/t/002_basic_io.t b/t/002_basic_io.t index b74eeed..bef8ba4 100644 --- a/t/002_basic_io.t +++ b/t/002_basic_io.t @@ -22,18 +22,18 @@ BEGIN { package Foo; use Moose; use MooseX::Storage; - + with Storage( format => 'JSON', io => 'File', ); - + has 'number' => (is => 'ro', isa => 'Int'); has 'string' => (is => 'ro', isa => 'Str'); - has 'float' => (is => 'ro', isa => 'Num'); + has 'float' => (is => 'ro', isa => 'Num'); has 'array' => (is => 'ro', isa => 'ArrayRef'); - has 'hash' => (is => 'ro', isa => 'HashRef'); - has 'object' => (is => 'ro', isa => 'Object'); + has 'hash' => (is => 'ro', isa => 'HashRef'); + has 'object' => (is => 'ro', isa => 'Object'); } my $file = catfile($dir, 'temp.json'); diff --git a/t/002_basic_w_subtypes.t b/t/002_basic_w_subtypes.t index 1f99409..4b5ee5f 100644 --- a/t/002_basic_w_subtypes.t +++ b/t/002_basic_w_subtypes.t @@ -10,8 +10,8 @@ BEGIN { =pod -This extends the 001_basic test to -show that subtypes will DWIM in most +This extends the 001_basic test to +show that subtypes will DWIM in most cases. =cut @@ -25,25 +25,25 @@ cases. use Scalar::Util 'looks_like_number'; - with Storage; - - subtype 'Natural' + with Storage; + + subtype 'Natural' => as 'Int' => where { $_ > 0 }; - - subtype 'HalfNum' + + subtype 'HalfNum' => as 'Num' - => where { "$_" =~ /\.5$/ }; - + => where { "$_" =~ /\.5$/ }; + subtype 'FooString' => as 'Str' => where { lc($_) eq 'foo' }; - - subtype 'IntArray' + + subtype 'IntArray' => as 'ArrayRef' => where { scalar grep { looks_like_number($_) } @{$_} }; - subtype 'UndefHash' + subtype 'UndefHash' => as 'HashRef' => where { scalar grep { !defined($_) } values %{$_} }; @@ -65,7 +65,7 @@ cases. object => Foo->new( number => 2 ), ); isa_ok( $foo, 'Foo' ); - + cmp_deeply( $foo->pack, { @@ -75,10 +75,10 @@ cases. float => 10.5, array => [ 1 .. 10 ], hash => { map { $_ => undef } ( 1 .. 10 ) }, - object => { - __CLASS__ => 'Foo', - number => 2 - }, + object => { + __CLASS__ => 'Foo', + number => 2 + }, }, '... got the right frozen class' ); @@ -93,11 +93,11 @@ cases. float => 10.5, array => [ 1 .. 10 ], hash => { map { $_ => undef } ( 1 .. 10 ) }, - object => { - __CLASS__ => 'Foo', - number => 2 - }, - } + object => { + __CLASS__ => 'Foo', + number => 2 + }, + } ); isa_ok( $foo, 'Foo' ); diff --git a/t/003_basic_w_embedded_objects.t b/t/003_basic_w_embedded_objects.t index 65a5001..03ef4af 100644 --- a/t/003_basic_w_embedded_objects.t +++ b/t/003_basic_w_embedded_objects.t @@ -10,8 +10,8 @@ BEGIN { =pod -This test checks the single level -expansion and collpasing of the +This test checks the single level +expansion and collpasing of the ArrayRef and HashRef type handlers. =cut @@ -22,30 +22,30 @@ ArrayRef and HashRef type handlers. use MooseX::Storage; with Storage; - + has 'number' => (is => 'ro', isa => 'Int'); - + package Foo; use Moose; use MooseX::Storage; - with Storage; + with Storage; - has 'bars' => ( - is => 'ro', - isa => 'ArrayRef' + has 'bars' => ( + is => 'ro', + isa => 'ArrayRef' ); - + package Baz; use Moose; use MooseX::Storage; - with Storage; + with Storage; - has 'bars' => ( - is => 'ro', - isa => 'HashRef' - ); + has 'bars' => ( + is => 'ro', + isa => 'HashRef' + ); } { @@ -53,19 +53,19 @@ ArrayRef and HashRef type handlers. bars => [ map { Bar->new(number => $_) } (1 .. 10) ] ); isa_ok( $foo, 'Foo' ); - + cmp_deeply( $foo->pack, { __CLASS__ => 'Foo', - bars => [ + bars => [ map { { __CLASS__ => 'Bar', number => $_, - } + } } (1 .. 10) - ], + ], }, '... got the right frozen class' ); @@ -75,15 +75,15 @@ ArrayRef and HashRef type handlers. my $foo = Foo->unpack( { __CLASS__ => 'Foo', - bars => [ + bars => [ map { { __CLASS__ => 'Bar', number => $_, - } + } } (1 .. 10) - ], - } + ], + } ); isa_ok( $foo, 'Foo' ); @@ -99,7 +99,7 @@ ArrayRef and HashRef type handlers. bars => { map { ($_ => Bar->new(number => $_)) } (1 .. 10) } ); isa_ok( $baz, 'Baz' ); - + cmp_deeply( $baz->pack, { @@ -109,9 +109,9 @@ ArrayRef and HashRef type handlers. ($_ => { __CLASS__ => 'Bar', number => $_, - }) + }) } (1 .. 10) - }, + }, }, '... got the right frozen class' ); @@ -126,10 +126,10 @@ ArrayRef and HashRef type handlers. ($_ => { __CLASS__ => 'Bar', number => $_, - }) + }) } (1 .. 10) - }, - } + }, + } ); isa_ok( $baz, 'Baz' ); diff --git a/t/004_w_cycles.t b/t/004_w_cycles.t index c816b62..9664cba 100644 --- a/t/004_w_cycles.t +++ b/t/004_w_cycles.t @@ -14,7 +14,7 @@ BEGIN { This test demonstrates two things: - cycles will not work in the default engine -- you can use a special metaclass to tell +- you can use a special metaclass to tell MooseX::Storage to skip an attribute =cut @@ -33,9 +33,9 @@ This test demonstrates two things: { my $circular = Circular->new; isa_ok($circular, 'Circular'); - + $circular->cycle($circular); - + like(exception { $circular->pack; }, qr/^Basic Engine does not support cycles/, @@ -61,19 +61,19 @@ This test demonstrates two things: with Storage; has 'node' => (is => 'rw'); - + has 'children' => ( - is => 'ro', - isa => 'ArrayRef', + is => 'ro', + isa => 'ArrayRef', default => sub {[]} ); - + has 'parent' => ( metaclass => 'DoNotSerialize', - is => 'rw', + is => 'rw', isa => 'Tree', ); - + sub add_child { my ($self, $child) = @_; $child->parent($self); @@ -84,28 +84,28 @@ This test demonstrates two things: { my $t = Tree->new(node => 100); isa_ok($t, 'Tree'); - + cmp_deeply( - $t->pack, + $t->pack, { __CLASS__ => 'Tree', node => 100, children => [], }, '... got the right packed version'); - + my $t2 = Tree->new(node => 200); - isa_ok($t2, 'Tree'); - + isa_ok($t2, 'Tree'); + $t->add_child($t2); - + cmp_deeply($t->children, [ $t2 ], '... got the right children in $t'); - + is($t2->parent, $t, '... created the cycle correctly'); - isa_ok($t2->parent, 'Tree'); - + isa_ok($t2->parent, 'Tree'); + cmp_deeply( - $t->pack, + $t->pack, { __CLASS__ => 'Tree', node => 100, @@ -113,18 +113,18 @@ This test demonstrates two things: { __CLASS__ => 'Tree', node => 200, - children => [], - } + children => [], + } ], }, - '... got the right packed version (with parent attribute skipped in child)'); - + '... got the right packed version (with parent attribute skipped in child)'); + cmp_deeply( - $t2->pack, + $t2->pack, { __CLASS__ => 'Tree', node => 200, - children => [], + children => [], }, '... got the right packed version (with parent attribute skipped)'); } @@ -134,7 +134,7 @@ This test demonstrates two things: use Moose; use MooseX::Storage; with Storage; - + has 'x' => ( is => 'rw', isa => 'HashRef' ); has 'y' => ( is => 'rw', isa => 'HashRef' ); } @@ -153,13 +153,13 @@ This test demonstrates two things: ok( Double->unpack( $pack || {} ), " And unpacked again" ); } - + my $pack = $double->pack( engine_traits => [qw/DisableCycleDetection/] ); ok( $pack, " Object packs when cycle check is disabled"); ok( Double->unpack( $pack ), " And unpacked again" ); -} +} ### the same as above, but now done with a trait ### this fails with cycle detection on @@ -167,7 +167,7 @@ This test demonstrates two things: use Moose; use MooseX::Storage; with Storage( traits => ['DisableCycleDetection'] ); - + has 'x' => ( is => 'rw', isa => 'HashRef' ); has 'y' => ( is => 'rw', isa => 'HashRef' ); } @@ -179,4 +179,4 @@ This test demonstrates two things: ok( $pack, "Object packs with DisableCycleDetection trait"); ok( DoubleNoCycle->unpack( $pack ), " Unpacked again" ); -} +} diff --git a/t/005_w_versions_and_authority_check.t b/t/005_w_versions_and_authority_check.t index 539567e..50b5a15 100644 --- a/t/005_w_versions_and_authority_check.t +++ b/t/005_w_versions_and_authority_check.t @@ -11,7 +11,7 @@ BEGIN { =pod -This tests that the version and authority +This tests that the version and authority checks are performed upon object expansion. =cut @@ -20,27 +20,27 @@ checks are performed upon object expansion. package Bar; use Moose; use MooseX::Storage; - + our $VERSION = '0.01'; our $AUTHORITY = 'cpan:JRANDOM'; with Storage; - + has 'number' => (is => 'ro', isa => 'Int'); - + package Foo; use Moose; use MooseX::Storage; our $VERSION = '0.01'; - our $AUTHORITY = 'cpan:JRANDOM'; + our $AUTHORITY = 'cpan:JRANDOM'; - with Storage; + with Storage; - has 'bar' => ( - is => 'ro', - isa => 'Bar' - ); + has 'bar' => ( + is => 'ro', + isa => 'Bar' + ); } { @@ -48,7 +48,7 @@ checks are performed upon object expansion. bar => Bar->new(number => 1) ); isa_ok( $foo, 'Foo' ); - + cmp_deeply( $foo->pack, { @@ -56,7 +56,7 @@ checks are performed upon object expansion. bar => { __CLASS__ => 'Bar-0.01-cpan:JRANDOM', number => 1, - } + } }, '... got the right frozen class' ); @@ -69,16 +69,16 @@ checks are performed upon object expansion. bar => { __CLASS__ => 'Bar-0.01-cpan:JRANDOM', number => 1, - } - }, + } + }, ); isa_ok( $foo, 'Foo' ); isa_ok( $foo->bar, 'Bar' ); is( $foo->bar->number, 1 , '... got the right number too' ); - + } -Moose::Meta::Class->create('Bar', +Moose::Meta::Class->create('Bar', version => '0.02', authority => 'cpan:JRANDOM', ); @@ -90,12 +90,12 @@ ok(exception { bar => { __CLASS__ => 'Bar-0.01-cpan:JRANDOM', number => 1, - } - } + } + } ); }, '... could not unpack, versions are different ' . $@); -Moose::Meta::Class->create('Bar', +Moose::Meta::Class->create('Bar', version => '0.01', authority => 'cpan:DSTATIC', ); @@ -107,7 +107,7 @@ ok(exception { bar => { __CLASS__ => 'Bar-0.01-cpan:JRANDOM', number => 1, - } - } + } + } ); }, '... could not unpack, authorities are different'); diff --git a/t/006_w_custom_type_handlers.t b/t/006_w_custom_type_handlers.t index bc59968..e028a42 100644 --- a/t/006_w_custom_type_handlers.t +++ b/t/006_w_custom_type_handlers.t @@ -7,29 +7,29 @@ use Test::Fatal; BEGIN { use_ok('MooseX::Storage'); - use_ok('MooseX::Storage::Engine'); + use_ok('MooseX::Storage::Engine'); } =pod -This is just a simple example of defining +This is just a simple example of defining a custom type handler to take care of custom -inflate and deflate needs. +inflate and deflate needs. =cut { package Bar; use Moose; - + has 'baz' => (is => 'rw', isa => 'Str'); - has 'boo' => (is => 'rw', isa => 'Str'); - + has 'boo' => (is => 'rw', isa => 'Str'); + sub encode { my $self = shift; $self->baz . '|' . $self->boo; } - + sub decode { my ($class, $packed) = @_; my ($baz, $boo) = split /\|/ => $packed; @@ -38,20 +38,20 @@ inflate and deflate needs. boo => $boo, ); } - + MooseX::Storage::Engine->add_custom_type_handler( 'Bar' => ( expand => sub { Bar->decode(shift) }, collapse => sub { (shift)->encode }, ) ); - + package Foo; use Moose; use MooseX::Storage; - + with Storage; - + has 'bar' => ( is => 'ro', isa => 'Bar', @@ -80,9 +80,9 @@ $foo->pack, bar => "BAZ|BOO", }); isa_ok($foo, 'Foo'); - - isa_ok($foo->bar, 'Bar'); - + + isa_ok($foo->bar, 'Bar'); + is($foo->bar->baz, 'BAZ', '... got the right stuff'); is($foo->bar->boo, 'BOO', '... got the right stuff'); } diff --git a/t/007_false.t b/t/007_false.t index fbd80f1..3035651 100644 --- a/t/007_false.t +++ b/t/007_false.t @@ -28,9 +28,9 @@ BEGIN { boolean => 0, ); isa_ok( $foo, 'Foo' ); - + is($foo->boolean, 0, '... got the right boolean value'); - + cmp_deeply( $foo->pack, { @@ -50,7 +50,7 @@ BEGIN { number => 0, string => '', boolean => 0, - } + } ); isa_ok( $foo, 'Foo' ); diff --git a/t/008_do_not_serialize.t b/t/008_do_not_serialize.t index f262dbd..0748c5d 100644 --- a/t/008_do_not_serialize.t +++ b/t/008_do_not_serialize.t @@ -19,30 +19,30 @@ BEGIN { has 'bar' => ( metaclass => 'DoNotSerialize', is => 'rw', - default => sub { 'BAR' } + default => sub { 'BAR' } ); - + has 'baz' => ( traits => [ 'DoNotSerialize' ], is => 'rw', - default => sub { 'BAZ' } - ); - + default => sub { 'BAZ' } + ); + has 'gorch' => ( - is => 'rw', + is => 'rw', default => sub { 'GORCH' } - ); + ); 1; } { my $foo = Foo->new; isa_ok($foo, 'Foo'); - + is($foo->bar, 'BAR', '... got the value we expected'); is($foo->baz, 'BAZ', '... got the value we expected'); is($foo->gorch, 'GORCH', '... got the value we expected'); - + cmp_deeply( $foo->pack, { @@ -66,36 +66,36 @@ BEGIN { is => 'rw', isa => 'Object', # type constraint is important ); - + has zot => ( default => sub { $$ }, is => 'rw', - ); + ); } { my $obj = bless {}; my $bar = Bar->new( foo => $obj ); - + ok( $bar, "New object created" ); is( $bar->foo, $obj, " ->foo => $obj" ); is( $bar->zot, $$, " ->zot => $$" ); - + my $bpack = $bar->pack; cmp_deeply( $bpack, { __CLASS__ => 'Bar', zot => $$, }, " Packed correctly" ); - + eval { Bar->unpack( $bpack ) }; ok( $@, " Unpack without required attribute fails" ); like( $@, qr/foo/, " Proper error recorded" ); - + my $bar2 = Bar->unpack( $bpack, inject => { foo => bless {} } ); - ok( $bar2, " Unpacked correctly with foo => Object"); -} - - - - + ok( $bar2, " Unpacked correctly with foo => Object"); +} + + + + diff --git a/t/009_do_not_serialize_lazy.t b/t/009_do_not_serialize_lazy.t index cb76f6b..9242065 100644 --- a/t/009_do_not_serialize_lazy.t +++ b/t/009_do_not_serialize_lazy.t @@ -18,8 +18,8 @@ BEGIN { has 'x' => (is => 'rw', lazy_build => 1 ); has 'y' => (is => 'rw', lazy_build => 1 ); has 'z' => (is => 'rw', builder => '_build_z' ); - - + + sub _build_x { 'x' } sub _build_y { 'y' } sub _build_z { 'z' } @@ -36,8 +36,8 @@ is( $href->{'x'}, $$, " x => $$" ); is( $href->{'z'}, 'z', " z => z" ); ok( not(exists($href->{'y'})), " y does not exist" ); -cmp_deeply( - $href, +cmp_deeply( + $href, { '__CLASS__' => 'Point', 'x' => $$, 'z' => 'z' diff --git a/t/011_basic_json_w_utf8.t b/t/011_basic_json_w_utf8.t index 329f64b..6969c11 100644 --- a/t/011_basic_json_w_utf8.t +++ b/t/011_basic_json_w_utf8.t @@ -9,11 +9,11 @@ use Test::Requires { }; BEGIN { - # NOTE: - # this is because JSON::XS is + # NOTE: + # this is because JSON::XS is # the only one which really gets # utf8 correct - # - SL + # - SL BEGIN { $ENV{JSON_ANY_ORDER} = qw(XS); $ENV{JSON_ANY_CONFIG} = "utf8=0,canonical=1"; @@ -29,7 +29,7 @@ BEGIN { use MooseX::Storage; with Storage( 'format' => 'JSON' ); - + has 'utf8_string' => ( is => 'rw', isa => 'Str', @@ -49,14 +49,14 @@ BEGIN { my $foo2 = Foo->thaw($json); isa_ok( $foo, 'Foo' ); - - is($foo2->utf8_string, - "ネットスーパー (Internet Shopping)", + + is($foo2->utf8_string, + "ネットスーパー (Internet Shopping)", '... got the string we expected'); - + is($foo2->freeze, '{"__CLASS__":"Foo","utf8_string":"ネットスーパー (Internet Shopping)"}', - '... got the right JSON'); + '... got the right JSON'); } { @@ -66,15 +66,15 @@ BEGIN { $test_string = "ネットスーパー (Internet Shopping)"; no utf8; } - + ok(utf8::is_utf8($test_string), '... got a utf8 string'); - ok(utf8::valid($test_string), '... got a valid utf8 string'); - + ok(utf8::valid($test_string), '... got a valid utf8 string'); + Encode::_utf8_off($test_string); - + ok(!utf8::is_utf8($test_string), '... no longer is utf8 string'); - ok(utf8::valid($test_string), '... got a valid utf8 string'); - + ok(utf8::valid($test_string), '... got a valid utf8 string'); + my $foo = Foo->new( utf8_string => $test_string ); @@ -84,11 +84,11 @@ BEGIN { ok(utf8::valid($foo->utf8_string), '... but is a valid utf8 string'); my $json = $foo->freeze; - + ok(utf8::is_utf8($json), '... is a utf8 string now'); - ok(utf8::valid($json), '... got a valid utf8 string'); + ok(utf8::valid($json), '... got a valid utf8 string'); is($json, '{"__CLASS__":"Foo","utf8_string":"ネットスーパー (Internet Shopping)"}', - '... got the right JSON'); + '... got the right JSON'); } diff --git a/t/030_with_checksum.t b/t/030_with_checksum.t index 18934f8..0715831 100644 --- a/t/030_with_checksum.t +++ b/t/030_with_checksum.t @@ -41,9 +41,9 @@ BEGIN { object => Foo->new( number => 2 ), ); isa_ok( $foo, 'Foo' ); - + my $packed = $foo->pack; - + cmp_deeply( $packed, { @@ -54,11 +54,11 @@ BEGIN { float => 10.5, array => [ 1 .. 10 ], hash => { map { $_ => undef } ( 1 .. 10 ) }, - object => { - __CLASS__ => 'Foo', - __DIGEST__ => re('[0-9a-f]+'), - number => 2 - }, + object => { + __CLASS__ => 'Foo', + __DIGEST__ => re('[0-9a-f]+'), + number => 2 + }, }, '... got the right frozen class' ); @@ -68,7 +68,7 @@ BEGIN { $foo2 = Foo->unpack($packed); }, undef, '... unpacked okay'); isa_ok($foo2, 'Foo'); - + cmp_deeply( $foo2->pack, { @@ -79,14 +79,14 @@ BEGIN { float => 10.5, array => [ 1 .. 10 ], hash => { map { $_ => undef } ( 1 .. 10 ) }, - object => { - __CLASS__ => 'Foo', - __DIGEST__ => re('[0-9a-f]+'), - number => 2 - }, + object => { + __CLASS__ => 'Foo', + __DIGEST__ => re('[0-9a-f]+'), + number => 2 + }, }, '... got the right frozen class' - ); + ); } { diff --git a/t/040_basic_utils.t b/t/040_basic_utils.t index 1079688..8d2e299 100644 --- a/t/040_basic_utils.t +++ b/t/040_basic_utils.t @@ -5,7 +5,7 @@ use Test::More tests => 5; BEGIN { use_ok('MooseX::Storage'); - use_ok('MooseX::Storage::Util'); + use_ok('MooseX::Storage::Util'); } my $packed = { @@ -15,16 +15,16 @@ my $packed = { float => 10.5, array => [ 1 .. 10 ], hash => { map { $_ => undef } ( 1 .. 10 ) }, - object => { - __CLASS__ => 'Foo', - number => 2 - }, + object => { + __CLASS__ => 'Foo', + number => 2 + }, }; my $json = '{"array":[1,2,3,4,5,6,7,8,9,10],"hash":{"6":null,"3":null,"7":null,"9":null,"2":null,"8":null,"1":null,"4":null,"10":null,"5":null},"float":10.5,"object":{"number":2,"__CLASS__":"Foo"},"number":10,"__CLASS__":"Foo","string":"foo"}'; -my $yaml = q{--- +my $yaml = q{--- __CLASS__: Foo -array: +array: - 1 - 2 - 3 @@ -36,7 +36,7 @@ array: - 9 - 10 float: 10.5 -hash: +hash: 1: ~ 10: ~ 2: ~ @@ -48,38 +48,38 @@ hash: 8: ~ 9: ~ number: 10 -object: +object: __CLASS__: Foo number: 2 string: foo }; -is('Foo', MooseX::Storage::Util->peek($packed), +is('Foo', MooseX::Storage::Util->peek($packed), '... got the right class name from the packed item'); SKIP: { - my $classname = eval { - MooseX::Storage::Util->peek($json => ('format' => 'JSON')) + my $classname = eval { + MooseX::Storage::Util->peek($json => ('format' => 'JSON')) }; if ($@ =~ /^Could not load JSON module because/) { skip "No JSON module found", 1; } - is('Foo', $classname, + is('Foo', $classname, '... got the right class name from the json item'); } SKIP: { - my $classname = eval { + my $classname = eval { MooseX::Storage::Util->peek($yaml => ('format' => 'YAML')) }; if ($@ =~ /^Could not load YAML module because/ or $@ =~ /^Can't locate Best/ ) { skip "No YAML module found", 1; - } - - is('Foo', $classname, + } + + is('Foo', $classname, '... got the right class name from the yaml item'); } diff --git a/t/050_basic_storable.t b/t/050_basic_storable.t index 8a1ce3f..d659666 100644 --- a/t/050_basic_storable.t +++ b/t/050_basic_storable.t @@ -36,7 +36,7 @@ BEGIN { object => Foo->new( number => 2 ), ); isa_ok( $foo, 'Foo' ); - + my $stored = $foo->freeze; my $struct = Storable::thaw($stored); @@ -46,9 +46,9 @@ BEGIN { '__CLASS__' => 'Foo', 'float' => 10.5, 'number' => 10, - 'string' => 'foo', + 'string' => 'foo', 'array' => [ 1 .. 10], - 'hash' => { map { $_ => undef } 1 .. 10 }, + 'hash' => { map { $_ => undef } 1 .. 10 }, 'object' => { '__CLASS__' => 'Foo', 'number' => 2 @@ -63,15 +63,15 @@ BEGIN { '__CLASS__' => 'Foo', 'float' => 10.5, 'number' => 10, - 'string' => 'foo', + 'string' => 'foo', 'array' => [ 1 .. 10], - 'hash' => { map { $_ => undef } 1 .. 10 }, + 'hash' => { map { $_ => undef } 1 .. 10 }, 'object' => { '__CLASS__' => 'Foo', 'number' => 2 }, }); - + my $foo = Foo->thaw($stored); isa_ok( $foo, 'Foo' ); diff --git a/t/060_basic_deferred.t b/t/060_basic_deferred.t index 3011b8a..330548a 100644 --- a/t/060_basic_deferred.t +++ b/t/060_basic_deferred.t @@ -59,7 +59,7 @@ diag('Using implementation: ', YAML::Any->implementation); { my $foo = Foo->thaw( '{"array":[1,2,3,4,5,6,7,8,9,10],"hash":{"6":null,"3":null,"7":null,"9":null,"2":null,"8":null,"1":null,"4":null,"10":null,"5":null},"float":10.5,"object":{"number":2,"__CLASS__":"Foo"},"number":10,"__CLASS__":"Foo","string":"foo"}', - { 'format' => 'JSON' } + { 'format' => 'JSON' } ); isa_ok( $foo, 'Foo' ); @@ -88,7 +88,7 @@ diag('Using implementation: ', YAML::Any->implementation); object => Foo->new( number => 2 ), ); isa_ok( $foo, 'Foo' ); - + my $stored = $foo->freeze({ 'format' => 'Storable' }); my $struct = Storable::thaw($stored); @@ -98,9 +98,9 @@ diag('Using implementation: ', YAML::Any->implementation); '__CLASS__' => 'Foo', 'float' => 10.5, 'number' => 10, - 'string' => 'foo', + 'string' => 'foo', 'array' => [ 1 .. 10], - 'hash' => { map { $_ => undef } 1 .. 10 }, + 'hash' => { map { $_ => undef } 1 .. 10 }, 'object' => { '__CLASS__' => 'Foo', 'number' => 2 @@ -115,15 +115,15 @@ diag('Using implementation: ', YAML::Any->implementation); '__CLASS__' => 'Foo', 'float' => 10.5, 'number' => 10, - 'string' => 'foo', + 'string' => 'foo', 'array' => [ 1 .. 10], - 'hash' => { map { $_ => undef } 1 .. 10 }, + 'hash' => { map { $_ => undef } 1 .. 10 }, 'object' => { '__CLASS__' => 'Foo', 'number' => 2 }, }); - + my $foo = Foo->thaw($stored, { 'format' => 'Storable' }); isa_ok( $foo, 'Foo' ); diff --git a/t/061_basic_deferred_w_io.t b/t/061_basic_deferred_w_io.t index 0868ad8..8629743 100644 --- a/t/061_basic_deferred_w_io.t +++ b/t/061_basic_deferred_w_io.t @@ -22,15 +22,15 @@ BEGIN { package Foo; use Moose; use MooseX::Storage; - + with 'MooseX::Storage::Deferred'; - + has 'number' => (is => 'ro', isa => 'Int'); has 'string' => (is => 'ro', isa => 'Str'); - has 'float' => (is => 'ro', isa => 'Num'); + has 'float' => (is => 'ro', isa => 'Num'); has 'array' => (is => 'ro', isa => 'ArrayRef'); - has 'hash' => (is => 'ro', isa => 'HashRef'); - has 'object' => (is => 'ro', isa => 'Object'); + has 'hash' => (is => 'ro', isa => 'HashRef'); + has 'object' => (is => 'ro', isa => 'Object'); } my $file = catfile($dir, 'temp.json'); diff --git a/t/070_basic_maybe.t b/t/070_basic_maybe.t index 7d8feb7..a3d9b39 100644 --- a/t/070_basic_maybe.t +++ b/t/070_basic_maybe.t @@ -36,7 +36,7 @@ BEGIN { object => Foo->new( number => 2 ), ); isa_ok( $foo, 'Foo' ); - + cmp_deeply( $foo->pack, { @@ -47,10 +47,10 @@ BEGIN { float => 10.5, array => [ 1 .. 10 ], hash => { map { $_ => undef } ( 1 .. 10 ) }, - object => { - __CLASS__ => 'Foo', - number => 2 - }, + object => { + __CLASS__ => 'Foo', + number => 2 + }, }, '... got the right frozen class' ); @@ -66,11 +66,11 @@ BEGIN { float => 10.5, array => [ 1 .. 10 ], hash => { map { $_ => undef } ( 1 .. 10 ) }, - object => { - __CLASS__ => 'Foo', - number => 2 - }, - } + object => { + __CLASS__ => 'Foo', + number => 2 + }, + } ); isa_ok( $foo, 'Foo' ); @@ -100,25 +100,25 @@ BEGIN { use Scalar::Util 'looks_like_number'; - with Storage; - - subtype 'Natural' + with Storage; + + subtype 'Natural' => as 'Int' => where { $_ > 0 }; - - subtype 'HalfNum' + + subtype 'HalfNum' => as 'Num' - => where { "$_" =~ /\.5$/ }; - + => where { "$_" =~ /\.5$/ }; + subtype 'FooString' => as 'Str' => where { lc($_) eq 'foo' }; - - subtype 'IntArray' + + subtype 'IntArray' => as 'ArrayRef' => where { scalar grep { looks_like_number($_) } @{$_} }; - subtype 'UndefHash' + subtype 'UndefHash' => as 'HashRef' => where { scalar grep { !defined($_) } values %{$_} }; @@ -140,7 +140,7 @@ BEGIN { object => Foo->new( number => 2 ), ); isa_ok( $foo, 'Foo' ); - + cmp_deeply( $foo->pack, { @@ -150,10 +150,10 @@ BEGIN { float => 10.5, array => [ 1 .. 10 ], hash => { map { $_ => undef } ( 1 .. 10 ) }, - object => { - __CLASS__ => 'Foo', - number => 2 - }, + object => { + __CLASS__ => 'Foo', + number => 2 + }, }, '... got the right frozen class' ); @@ -168,11 +168,11 @@ BEGIN { float => 10.5, array => [ 1 .. 10 ], hash => { map { $_ => undef } ( 1 .. 10 ) }, - object => { - __CLASS__ => 'Foo', - number => 2 - }, - } + object => { + __CLASS__ => 'Foo', + number => 2 + }, + } ); isa_ok( $foo, 'Foo' ); diff --git a/t/100_io.t b/t/100_io.t index 361b6a5..9c91a88 100644 --- a/t/100_io.t +++ b/t/100_io.t @@ -20,15 +20,15 @@ BEGIN { package Foo; use Moose; use MooseX::Storage; - + with Storage(format => 'JSON', io => 'File'); - + has 'number' => (is => 'ro', isa => 'Int'); has 'string' => (is => 'ro', isa => 'Str'); - has 'float' => (is => 'ro', isa => 'Num'); + has 'float' => (is => 'ro', isa => 'Num'); has 'array' => (is => 'ro', isa => 'ArrayRef'); - has 'hash' => (is => 'ro', isa => 'HashRef'); - has 'object' => (is => 'ro', isa => 'Object'); + has 'hash' => (is => 'ro', isa => 'HashRef'); + has 'object' => (is => 'ro', isa => 'Object'); } my $file = catfile( $dir, 'temp.json' ); diff --git a/t/101_io_atomic.t b/t/101_io_atomic.t index 930b314..c14522b 100644 --- a/t/101_io_atomic.t +++ b/t/101_io_atomic.t @@ -21,15 +21,15 @@ BEGIN { package Foo; use Moose; use MooseX::Storage; - + with Storage(format => 'JSON', io => 'AtomicFile'); - + has 'number' => (is => 'ro', isa => 'Int'); has 'string' => (is => 'ro', isa => 'Str'); - has 'float' => (is => 'ro', isa => 'Num'); + has 'float' => (is => 'ro', isa => 'Num'); has 'array' => (is => 'ro', isa => 'ArrayRef'); - has 'hash' => (is => 'ro', isa => 'HashRef'); - has 'object' => (is => 'ro', isa => 'Object'); + has 'hash' => (is => 'ro', isa => 'HashRef'); + has 'object' => (is => 'ro', isa => 'Object'); } my $file = catfile($dir,'temp.json'); diff --git a/t/102_io_storable_file.t b/t/102_io_storable_file.t index 2e297a5..feb0175 100644 --- a/t/102_io_storable_file.t +++ b/t/102_io_storable_file.t @@ -15,15 +15,15 @@ BEGIN { package Foo; use Moose; use MooseX::Storage; - + with Storage(io => 'StorableFile'); - + has 'number' => (is => 'ro', isa => 'Int'); has 'string' => (is => 'ro', isa => 'Str'); - has 'float' => (is => 'ro', isa => 'Num'); + has 'float' => (is => 'ro', isa => 'Num'); has 'array' => (is => 'ro', isa => 'ArrayRef'); - has 'hash' => (is => 'ro', isa => 'HashRef'); - has 'object' => (is => 'ro', isa => 'Object'); + has 'hash' => (is => 'ro', isa => 'HashRef'); + has 'object' => (is => 'ro', isa => 'Object'); } my $file = catfile($dir,'temp.storable'); diff --git a/t/103_io_storable_file_custom.t b/t/103_io_storable_file_custom.t index f87148b..88093b8 100644 --- a/t/103_io_storable_file_custom.t +++ b/t/103_io_storable_file_custom.t @@ -16,15 +16,15 @@ BEGIN { package Foo; use Moose; use MooseX::Storage; - + with Storage(io => 'StorableFile'); - + has 'number' => (is => 'ro', isa => 'Int'); has 'string' => (is => 'rw', isa => 'Str'); - has 'float' => (is => 'ro', isa => 'Num'); + has 'float' => (is => 'ro', isa => 'Num'); has 'array' => (is => 'ro', isa => 'ArrayRef'); - has 'hash' => (is => 'ro', isa => 'HashRef'); - has 'object' => (is => 'ro', isa => 'Object'); + has 'hash' => (is => 'ro', isa => 'HashRef'); + has 'object' => (is => 'ro', isa => 'Object'); ## add some custom freeze/thaw hooks here ... @@ -58,7 +58,7 @@ my $file = catfile($dir,'temp.storable'); isa_ok($foo, 'Foo'); $foo->store($file); - + # check our custom freeze hook fired ... my $data = Storable::retrieve($file); cmp_deeply( @@ -67,17 +67,17 @@ my $file = catfile($dir,'temp.storable'); '__CLASS__' => 'Foo', 'float' => 10.5, 'number' => 10, - 'string' => 'HELLO WORLD', + 'string' => 'HELLO WORLD', 'array' => [ 1 .. 10], - 'hash' => { map { $_ => undef } 1 .. 10 }, + 'hash' => { map { $_ => undef } 1 .. 10 }, 'object' => { '__CLASS__' => 'Foo', 'number' => 2 }, }, '... got the data struct we expected' - ); - + ); + } { diff --git a/t/104_io_w_utf8.t b/t/104_io_w_utf8.t index 6ddb916..3af9d05 100644 --- a/t/104_io_w_utf8.t +++ b/t/104_io_w_utf8.t @@ -11,12 +11,12 @@ use Test::Requires { 'IO::AtomicFile' => 0.01, }; -BEGIN { - # NOTE: - # this is because JSON::XS is +BEGIN { + # NOTE: + # this is because JSON::XS is # the only one which really gets # utf8 correct - # - SL + # - SL BEGIN { $ENV{JSON_ANY_ORDER} = qw(XS); $ENV{JSON_ANY_CONFIG} = "utf8=0,canonical=1"; @@ -33,7 +33,7 @@ use utf8; use MooseX::Storage; with Storage( 'format' => 'JSON', 'io' => 'File' ); - + has 'utf8_string' => ( is => 'rw', isa => 'Str', @@ -46,16 +46,16 @@ my $file = catfile($dir,'temp.json'); { my $foo = Foo->new; isa_ok( $foo, 'Foo' ); - - $foo->store($file); + + $foo->store($file); } { my $foo = Foo->load($file); isa_ok($foo, 'Foo'); - is($foo->utf8_string, - "ネットスーパー (Internet Shopping)", + is($foo->utf8_string, + "ネットスーパー (Internet Shopping)", '... got the string we expected'); } @@ -68,18 +68,18 @@ unlink $file; utf8_string => 'Escritório' ); isa_ok( $foo, 'Foo' ); - - $foo->store($file); + + $foo->store($file); } { my $foo = Foo->load($file); isa_ok($foo, 'Foo'); - + ok(utf8::is_utf8($foo->utf8_string), '... the string is still utf8'); - is($foo->utf8_string, - "Escritório", + is($foo->utf8_string, + "Escritório", '... got the string we expected'); } diff --git a/t/105_io_atomic_w_utf8.t b/t/105_io_atomic_w_utf8.t index 83fa41c..333bc5a 100644 --- a/t/105_io_atomic_w_utf8.t +++ b/t/105_io_atomic_w_utf8.t @@ -11,12 +11,12 @@ use Test::Requires { 'IO::AtomicFile' => 0.01, }; -BEGIN { - # NOTE: - # this is because JSON::XS is +BEGIN { + # NOTE: + # this is because JSON::XS is # the only one which really gets # utf8 correct - # - SL + # - SL BEGIN { $ENV{JSON_ANY_ORDER} = qw(XS); $ENV{JSON_ANY_CONFIG} = "utf8=0,canonical=1"; @@ -33,7 +33,7 @@ use utf8; use MooseX::Storage; with Storage( 'format' => 'JSON', 'io' => 'AtomicFile' ); - + has 'utf8_string' => ( is => 'rw', isa => 'Str', @@ -46,16 +46,16 @@ my $file = catfile($dir, 'temp.json'); { my $foo = Foo->new; isa_ok( $foo, 'Foo' ); - - $foo->store($file); + + $foo->store($file); } { my $foo = Foo->load($file); isa_ok($foo, 'Foo'); - is($foo->utf8_string, - "ネットスーパー (Internet Shopping)", + is($foo->utf8_string, + "ネットスーパー (Internet Shopping)", '... got the string we expected'); } @@ -68,18 +68,18 @@ unlink $file; utf8_string => 'Escritório' ); isa_ok( $foo, 'Foo' ); - - $foo->store($file); + + $foo->store($file); } { my $foo = Foo->load($file); isa_ok($foo, 'Foo'); - + ok(utf8::is_utf8($foo->utf8_string), '... the string is still utf8'); - is($foo->utf8_string, - "Escritório", + is($foo->utf8_string, + "Escritório", '... got the string we expected'); }