9 'YAML::Any' => 0.01, # skip all if not installed
11 'Test::Without::Module' => 0.01,
15 Test::Without::Module->import(YAML::Any->order);
16 Test::Without::Module->unimport('YAML::XS');
18 use_ok('MooseX::Storage');
26 with Storage( 'format' => 'YAML' );
28 has 'number' => ( is => 'ro', isa => 'Int' );
29 has 'string' => ( is => 'ro', isa => 'Str' );
30 has 'float' => ( is => 'ro', isa => 'Num' );
31 has 'array' => ( is => 'ro', isa => 'ArrayRef' );
32 has 'hash' => ( is => 'ro', isa => 'HashRef' );
33 has 'object' => ( is => 'ro', isa => 'Object' );
42 hash => { map { $_ => undef } ( 1 .. 10 ) },
43 object => Foo->new( number => 2 ),
45 isa_ok( $foo, 'Foo' );
47 my $yaml = $foo->freeze;
49 my $bar = Foo->thaw( $yaml );
50 isa_ok( $bar, 'Foo' );
52 is( $bar->number, 10, '... got the right number' );
53 is( $bar->string, 'foo', '... got the right string' );
54 is( $bar->float, 10.5, '... got the right float' );
55 cmp_deeply( $bar->array, [ 1 .. 10 ], '... got the right array' );
58 { map { $_ => undef } ( 1 .. 10 ) },
59 '... got the right hash'
62 isa_ok( $bar->object, 'Foo' );
63 is( $bar->object->number, 2,
64 '... got the right number (in the embedded object)' );