-#!/usr/bin/perl
-
use strict;
use warnings;
-use Test::More no_plan => 1;
+use Test::More tests => 47;
+use Test::Deep;
BEGIN {
use_ok('MooseX::Storage');
=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
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'
+ );
}
{
bars => [ map { Bar->new(number => $_) } (1 .. 10) ]
);
isa_ok( $foo, 'Foo' );
-
- is_deeply(
+
+ cmp_deeply(
$foo->pack,
{
- __class__ => 'Foo',
- bars => [
+ __CLASS__ => 'Foo',
+ bars => [
map {
{
- __class__ => 'Bar',
+ __CLASS__ => 'Bar',
number => $_,
- }
+ }
} (1 .. 10)
- ],
+ ],
},
'... got the right frozen class'
);
{
my $foo = Foo->unpack(
{
- __class__ => 'Foo',
- bars => [
+ __CLASS__ => 'Foo',
+ bars => [
map {
{
- __class__ => 'Bar',
+ __CLASS__ => 'Bar',
number => $_,
- }
+ }
} (1 .. 10)
- ],
- }
+ ],
+ }
);
isa_ok( $foo, 'Foo' );
bars => { map { ($_ => Bar->new(number => $_)) } (1 .. 10) }
);
isa_ok( $baz, 'Baz' );
-
- is_deeply(
+
+ cmp_deeply(
$baz->pack,
{
- __class__ => 'Baz',
+ __CLASS__ => 'Baz',
bars => {
map {
($_ => {
- __class__ => 'Bar',
+ __CLASS__ => 'Bar',
number => $_,
- })
+ })
} (1 .. 10)
- },
+ },
},
'... got the right frozen class'
);
{
my $baz = Baz->unpack(
{
- __class__ => 'Baz',
+ __CLASS__ => 'Baz',
bars => {
map {
($_ => {
- __class__ => 'Bar',
+ __CLASS__ => 'Bar',
number => $_,
- })
+ })
} (1 .. 10)
- },
- }
+ },
+ }
);
isa_ok( $baz, 'Baz' );