X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=t%2F040_type_constraints%2Ffailing%2F011_container_type_constraint.t;fp=t%2F040_type_constraints%2Ffailing%2F011_container_type_constraint.t;h=0000000000000000000000000000000000000000;hb=fde8e43f95fe996fbc2a778aa259feeb04552171;hp=82f1b99b26ca3f849f1c10fce46653b4f29ad48d;hpb=0bdc9d38dfd3de07aad929f6629f8fa65d434c27;p=gitmo%2FMouse.git diff --git a/t/040_type_constraints/failing/011_container_type_constraint.t b/t/040_type_constraints/failing/011_container_type_constraint.t deleted file mode 100644 index 82f1b99..0000000 --- a/t/040_type_constraints/failing/011_container_type_constraint.t +++ /dev/null @@ -1,73 +0,0 @@ -#!/usr/bin/perl - -use strict; -use warnings; - -use Test::More tests => 24; -use Test::Exception; - -BEGIN { - use_ok('Mouse::Util::TypeConstraints'); - use_ok('Mouse::Meta::TypeConstraint::Parameterized'); -} - -# Array of Ints - -my $array_of_ints = Mouse::Meta::TypeConstraint::Parameterized->new( - name => 'ArrayRef[Int]', - parent => find_type_constraint('ArrayRef'), - type_parameter => find_type_constraint('Int'), -); -isa_ok($array_of_ints, 'Mouse::Meta::TypeConstraint::Parameterized'); -isa_ok($array_of_ints, 'Mouse::Meta::TypeConstraint'); - -ok($array_of_ints->check([ 1, 2, 3, 4 ]), '... [ 1, 2, 3, 4 ] passed successfully'); -ok(!$array_of_ints->check([qw/foo bar baz/]), '... [qw/foo bar baz/] failed successfully'); -ok(!$array_of_ints->check([ 1, 2, 3, qw/foo bar/]), '... [ 1, 2, 3, qw/foo bar/] failed successfully'); - -ok(!$array_of_ints->check(1), '... 1 failed successfully'); -ok(!$array_of_ints->check({}), '... {} failed successfully'); -ok(!$array_of_ints->check(sub { () }), '... sub { () } failed successfully'); - -# Hash of Ints - -my $hash_of_ints = Mouse::Meta::TypeConstraint::Parameterized->new( - name => 'HashRef[Int]', - parent => find_type_constraint('HashRef'), - type_parameter => find_type_constraint('Int'), -); -isa_ok($hash_of_ints, 'Mouse::Meta::TypeConstraint::Parameterized'); -isa_ok($hash_of_ints, 'Mouse::Meta::TypeConstraint'); - -ok($hash_of_ints->check({ one => 1, two => 2, three => 3 }), '... { one => 1, two => 2, three => 3 } passed successfully'); -ok(!$hash_of_ints->check({ 1 => 'one', 2 => 'two', 3 => 'three' }), '... { 1 => one, 2 => two, 3 => three } failed successfully'); -ok(!$hash_of_ints->check({ 1 => 'one', 2 => 'two', three => 3 }), '... { 1 => one, 2 => two, three => 3 } failed successfully'); - -ok(!$hash_of_ints->check(1), '... 1 failed successfully'); -ok(!$hash_of_ints->check([]), '... [] failed successfully'); -ok(!$hash_of_ints->check(sub { () }), '... sub { () } failed successfully'); - -# Array of Array of Ints - -my $array_of_array_of_ints = Mouse::Meta::TypeConstraint::Parameterized->new( - name => 'ArrayRef[ArrayRef[Int]]', - parent => find_type_constraint('ArrayRef'), - type_parameter => $array_of_ints, -); -isa_ok($array_of_array_of_ints, 'Mouse::Meta::TypeConstraint::Parameterized'); -isa_ok($array_of_array_of_ints, 'Mouse::Meta::TypeConstraint'); - -ok($array_of_array_of_ints->check( - [[ 1, 2, 3 ], [ 4, 5, 6 ]] -), '... [[ 1, 2, 3 ], [ 4, 5, 6 ]] passed successfully'); -ok(!$array_of_array_of_ints->check( - [[ 1, 2, 3 ], [ qw/foo bar/ ]] -), '... [[ 1, 2, 3 ], [ qw/foo bar/ ]] failed successfully'); - -{ - my $anon_type = Mouse::Util::TypeConstraints::find_or_parse_type_constraint('ArrayRef[Foo]'); - isa_ok( $anon_type, 'Mouse::Meta::TypeConstraint::Parameterized' ); - - my $param_type = $anon_type->type_parameter; - isa_ok( $param_type, 'Mouse::Meta::TypeConstraint::Class' ); -}