6 use Test::More tests => 11;
10 use_ok('MooseX::Storage');
15 This extends the 001_basic test to
16 show that subtypes will DWIM in most
25 use Moose::Util::TypeConstraints;
28 use Scalar::Util 'looks_like_number';
38 => where { "$_" =~ /\.5$/ };
42 => where { lc($_) eq 'foo' };
46 => where { scalar grep { looks_like_number($_) } @{$_} };
50 => where { scalar grep { !defined($_) } values %{$_} };
52 has 'number' => ( is => 'ro', isa => 'Natural' );
53 has 'string' => ( is => 'ro', isa => 'FooString' );
54 has 'float' => ( is => 'ro', isa => 'HalfNum' );
55 has 'array' => ( is => 'ro', isa => 'IntArray' );
56 has 'hash' => ( is => 'ro', isa => 'UndefHash' );
57 has 'object' => ( is => 'ro', isa => 'Foo' );
66 hash => { map { $_ => undef } ( 1 .. 10 ) },
67 object => Foo->new( number => 2 ),
69 isa_ok( $foo, 'Foo' );
79 hash => { map { $_ => undef } ( 1 .. 10 ) },
85 '... got the right frozen class'
90 my $foo = Foo->unpack(
97 hash => { map { $_ => undef } ( 1 .. 10 ) },
104 isa_ok( $foo, 'Foo' );
106 is( $foo->number, 10, '... got the right number' );
107 is( $foo->string, 'foo', '... got the right string' );
108 is( $foo->float, 10.5, '... got the right float' );
109 cmp_deeply( $foo->array, [ 1 .. 10 ], '... got the right array' );
112 { map { $_ => undef } ( 1 .. 10 ) },
113 '... got the right hash'
116 isa_ok( $foo->object, 'Foo' );
117 is( $foo->object->number, 2,
118 '... got the right number (in the embedded object)' );