X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=t%2Ftype_constraints%2Futil_type_constraints.t;h=04dd3aab9a24c61ddbed7866903bb53cce1a43d5;hb=rfc%2Fdeprecate-nonarrayref-enum;hp=2b26d5f4cd4b021c2f18ca983656530f9125fe84;hpb=829433c47061dd70a608bfcd940113c4172b6950;p=gitmo%2FMoose.git diff --git a/t/type_constraints/util_type_constraints.t b/t/type_constraints/util_type_constraints.t index 2b26d5f..04dd3aa 100644 --- a/t/type_constraints/util_type_constraints.t +++ b/t/type_constraints/util_type_constraints.t @@ -188,44 +188,4 @@ like( exception {$r->add_type_constraint(bless {}, 'SomeClass')}, qr/not a valid like( exception { subtype 'Foo' }, qr/cannot consist solely of a name/, 'Cannot call subtype with a single string argument' ); } -# Back-compat for being called without sugar. Previously, calling with -# sugar was indistinguishable from calling directly. - -{ - no warnings 'redefine'; - *Moose::Deprecated::deprecated = sub { return }; -} - -{ - my $type = type( 'Number2', sub { Scalar::Util::looks_like_number($_) } ); - - ok( $type->check(5), '... this is a Num' ); - ok( ! $type->check('Foo'), '... this is not a Num' ); -} - -{ - # anon subtype - my $subtype = subtype( 'Number2', sub { $_ > 0 } ); - - ok( $subtype->check(5), '... this is a Natural'); - ok( ! $subtype->check(-5), '... this is not a Natural'); - ok( ! $subtype->check('Foo'), '... this is not a Natural'); -} - -{ - my $subtype = subtype( 'Natural2', 'Number2', sub { $_ > 0 } ); - - ok( $subtype->check(5), '... this is a Natural'); - ok( ! $subtype->check(-5), '... this is not a Natural'); - ok( ! $subtype->check('Foo'), '... this is not a Natural'); -} - -{ - my $subtype = subtype( 'Natural3', 'Number2' ); - - ok( $subtype->check(5), '... this is a Natural'); - ok( $subtype->check(-5), '... this is a Natural'); - ok( ! $subtype->check('Foo'), '... this is not a Natural'); -} - done_testing;