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