this is a shorter way of specifying the gitmo repository properly
[gitmo/MooseX-Storage.git] / t / 009_do_not_serialize_lazy.t
CommitLineData
76218b46 1use strict;
2use warnings;
3
4use Test::More 'no_plan';#tests => 6;
619ab942 5use Test::Deep;
9d3c60f5 6use Test::Fatal;
76218b46 7
8BEGIN {
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' );
c2dae5d8 21
22
76218b46 23 sub _build_x { 'x' }
24 sub _build_y { 'y' }
25 sub _build_z { 'z' }
26
27}
28
29my $p = Point->new( 'x' => $$ );
30ok( $p, "New object created" );
31
32my $href = $p->pack;
33
34ok( $href, " Object packed" );
35is( $href->{'x'}, $$, " x => $$" );
36is( $href->{'z'}, 'z', " z => z" );
37ok( not(exists($href->{'y'})), " y does not exist" );
38
c2dae5d8 39cmp_deeply(
40 $href,
76218b46 41 { '__CLASS__' => 'Point',
42 'x' => $$,
43 'z' => 'z'
44 }, " Deep check passed" );