ee539000ea67e2581d52ad2a150d915c601191f8
[gitmo/MooseX-Storage.git] / t / 007_false.t
1 #!/usr/bin/perl
2
3 use strict;
4 use warnings;
5
6 use Test::More tests => 7;
7
8 BEGIN {
9     use_ok('MooseX::Storage');
10 }
11
12 {
13
14     package Foo;
15     use Moose;
16     use MooseX::Storage;
17
18     with Storage;
19
20     has 'number'  => ( is => 'ro', isa => 'Int', default => 42 );
21     has 'string'  => ( is => 'ro', isa => 'Str', default => "true" );
22     has 'boolean' => ( is => 'ro', isa => 'Bool', default => 1 );
23 }
24
25 {
26     my $foo = Foo->new(
27         number  => 0,
28         string  => '',
29         boolean => 0,
30     );
31     isa_ok( $foo, 'Foo' );
32     
33     is_deeply(
34         $foo->pack,
35         {
36             __CLASS__ => 'Foo',
37             number    => 0,
38             string    => '',
39             boolean   => 0,
40         },
41         '... got the right frozen class'
42     );
43 }
44
45 {
46     my $foo = Foo->unpack(
47         {
48             __CLASS__ => 'Foo',
49             number    => 0,
50             string    => '',
51             boolean   => 0,
52         }        
53     );
54     isa_ok( $foo, 'Foo' );
55
56     is( $foo->number, 0,  '... got the right number' );
57     is( $foo->string, '', '... got the right string' );
58     ok( !$foo->boolean,   '... got the right boolean' );
59 }