4 use Test::More tests => 11;
8 use_ok('MooseX::Storage');
13 This extends the 001_basic test to
14 show that subtypes will DWIM in most
23 use Moose::Util::TypeConstraints;
26 use Scalar::Util 'looks_like_number';
36 => where { "$_" =~ /\.5$/ };
40 => where { lc($_) eq 'foo' };
44 => where { scalar grep { looks_like_number($_) } @{$_} };
48 => where { scalar grep { !defined($_) } values %{$_} };
50 has 'number' => ( is => 'ro', isa => 'Natural' );
51 has 'string' => ( is => 'ro', isa => 'FooString' );
52 has 'float' => ( is => 'ro', isa => 'HalfNum' );
53 has 'array' => ( is => 'ro', isa => 'IntArray' );
54 has 'hash' => ( is => 'ro', isa => 'UndefHash' );
55 has 'object' => ( is => 'ro', isa => 'Foo' );
64 hash => { map { $_ => undef } ( 1 .. 10 ) },
65 object => Foo->new( number => 2 ),
67 isa_ok( $foo, 'Foo' );
77 hash => { map { $_ => undef } ( 1 .. 10 ) },
83 '... got the right frozen class'
88 my $foo = Foo->unpack(
95 hash => { map { $_ => undef } ( 1 .. 10 ) },
102 isa_ok( $foo, 'Foo' );
104 is( $foo->number, 10, '... got the right number' );
105 is( $foo->string, 'foo', '... got the right string' );
106 is( $foo->float, 10.5, '... got the right float' );
107 cmp_deeply( $foo->array, [ 1 .. 10 ], '... got the right array' );
110 { map { $_ => undef } ( 1 .. 10 ) },
111 '... got the right hash'
114 isa_ok( $foo->object, 'Foo' );
115 is( $foo->object->number, 2,
116 '... got the right number (in the embedded object)' );