10 'YAML::Any' => 0.01, # skip all if not installed
12 'Test::Without::Module' => 0.01,
16 Test::Without::Module->import(YAML::Any->order);
17 Test::Without::Module->unimport('YAML::XS');
19 use_ok('MooseX::Storage');
27 with Storage( 'format' => 'YAML' );
29 has 'number' => ( is => 'ro', isa => 'Int' );
30 has 'string' => ( is => 'ro', isa => 'Str' );
31 has 'float' => ( is => 'ro', isa => 'Num' );
32 has 'array' => ( is => 'ro', isa => 'ArrayRef' );
33 has 'hash' => ( is => 'ro', isa => 'HashRef' );
34 has 'object' => ( is => 'ro', isa => 'Object' );
43 hash => { map { $_ => undef } ( 1 .. 10 ) },
44 object => Foo->new( number => 2 ),
46 isa_ok( $foo, 'Foo' );
48 my $yaml = $foo->freeze;
50 my $bar = Foo->thaw( $yaml );
51 isa_ok( $bar, 'Foo' );
53 is( $bar->number, 10, '... got the right number' );
54 is( $bar->string, 'foo', '... got the right string' );
55 is( $bar->float, 10.5, '... got the right float' );
56 cmp_deeply( $bar->array, [ 1 .. 10 ], '... got the right array' );
59 { map { $_ => undef } ( 1 .. 10 ) },
60 '... got the right hash'
63 isa_ok( $bar->object, 'Foo' );
64 is( $bar->object->number, 2,
65 '... got the right number (in the embedded object)' );