6 use Test::More tests => 11;
9 use_ok('MooseX::Storage');
14 This extends the 001_basic test to
15 show that subtypes will DWIM in most
24 use Moose::Util::TypeConstraints;
27 use Scalar::Util 'looks_like_number';
37 => where { "$_" =~ /\.5$/ };
41 => where { lc($_) eq 'foo' };
45 => where { scalar grep { looks_like_number($_) } @{$_} };
49 => where { scalar grep { !defined($_) } values %{$_} };
51 has 'number' => ( is => 'ro', isa => 'Natural' );
52 has 'string' => ( is => 'ro', isa => 'FooString' );
53 has 'float' => ( is => 'ro', isa => 'HalfNum' );
54 has 'array' => ( is => 'ro', isa => 'IntArray' );
55 has 'hash' => ( is => 'ro', isa => 'UndefHash' );
56 has 'object' => ( is => 'ro', isa => 'Foo' );
65 hash => { map { $_ => undef } ( 1 .. 10 ) },
66 object => Foo->new( number => 2 ),
68 isa_ok( $foo, 'Foo' );
78 hash => { map { $_ => undef } ( 1 .. 10 ) },
84 '... got the right frozen class'
89 my $foo = Foo->unpack(
96 hash => { map { $_ => undef } ( 1 .. 10 ) },
103 isa_ok( $foo, 'Foo' );
105 is( $foo->number, 10, '... got the right number' );
106 is( $foo->string, 'foo', '... got the right string' );
107 is( $foo->float, 10.5, '... got the right float' );
108 is_deeply( $foo->array, [ 1 .. 10 ], '... got the right array' );
111 { map { $_ => undef } ( 1 .. 10 ) },
112 '... got the right hash'
115 isa_ok( $foo->object, 'Foo' );
116 is( $foo->object->number, 2,
117 '... got the right number (in the embedded object)' );