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