1b19ea6d719973347efbdeb64ad9196aa04449ec
[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 => 8;
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($foo->boolean, 0, '... got the right boolean value');
34     
35     is_deeply(
36         $foo->pack,
37         {
38             __CLASS__ => 'Foo',
39             number    => 0,
40             string    => '',
41             boolean   => 0,
42         },
43         '... got the right frozen class'
44     );
45 }
46
47 {
48     my $foo = Foo->unpack(
49         {
50             __CLASS__ => 'Foo',
51             number    => 0,
52             string    => '',
53             boolean   => 0,
54         }        
55     );
56     isa_ok( $foo, 'Foo' );
57
58     is( $foo->number, 0,  '... got the right number' );
59     is( $foo->string, '', '... got the right string' );
60     ok( !$foo->boolean,   '... got the right boolean' );
61 }