Commit | Line | Data |
669c0055 |
1 | use strict; |
2 | use warnings; |
3 | |
917411c2 |
4 | use Test::More tests => 8; |
619ab942 |
5 | use Test::Deep; |
669c0055 |
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' ); |
c2dae5d8 |
31 | |
917411c2 |
32 | is($foo->boolean, 0, '... got the right boolean value'); |
c2dae5d8 |
33 | |
619ab942 |
34 | cmp_deeply( |
669c0055 |
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, |
c2dae5d8 |
53 | } |
669c0055 |
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 | } |