Test::Deep is already required; use it instead of is_deeply
[gitmo/MooseX-Storage.git] / t / 009_do_not_serialize_lazy.t
1 #!/usr/bin/perl
2
3 use strict;
4 use warnings;
5
6 use Test::More 'no_plan';#tests => 6;
7 use Test::Deep;
8 use Test::Fatal;
9
10 BEGIN {
11     use_ok('MooseX::Storage');
12 }
13
14 {   package Point;
15     use Moose;
16     use MooseX::Storage;
17
18     with Storage( traits => [qw|OnlyWhenBuilt|] );
19
20     has 'x' => (is => 'rw', lazy_build => 1 );
21     has 'y' => (is => 'rw', lazy_build => 1 );
22     has 'z' => (is => 'rw', builder => '_build_z' );
23     
24     
25     sub _build_x { 'x' }
26     sub _build_y { 'y' }
27     sub _build_z { 'z' }
28
29 }
30
31 my $p = Point->new( 'x' => $$ );
32 ok( $p,                         "New object created" );
33
34 my $href = $p->pack;
35
36 ok( $href,                      "   Object packed" );
37 is( $href->{'x'}, $$,           "       x => $$" );
38 is( $href->{'z'}, 'z',          "       z => z" );
39 ok( not(exists($href->{'y'})),  "       y does not exist" );
40
41 cmp_deeply( 
42     $href, 
43     { '__CLASS__' => 'Point',
44       'x' => $$,
45       'z' => 'z'
46     },                          "   Deep check passed" );