From: John Napiorkowski Date: Mon, 30 Mar 2015 16:51:00 +0000 (-0500) Subject: specificy minimum typetiny version (might solve issue in testing X-Git-Tag: 5.90089_002~16 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=catagits%2FCatalyst-Runtime.git;a=commitdiff_plain;h=8748abc507b9025f3bb4c806800e28cef79f1c0a;hp=4125a7aa23e419715662093c886e5cb38b20bb4b specificy minimum typetiny version (might solve issue in testing --- diff --git a/t/arg_constraints.t b/t/arg_constraints.t index 8bfa085..4c29a43 100644 --- a/t/arg_constraints.t +++ b/t/arg_constraints.t @@ -5,7 +5,7 @@ use utf8; BEGIN { use Test::More; - eval "use Type::Tiny; 1" || do { + eval "use Type::Tiny 1.000005; 1" || do { plan skip_all => "Trouble loading Type::Tiny and friends => $@"; }; } diff --git a/t/query_constraints.t b/t/query_constraints.t new file mode 100644 index 0000000..0eba004 --- /dev/null +++ b/t/query_constraints.t @@ -0,0 +1,74 @@ +use warnings; +use strict; +use HTTP::Request::Common; +use utf8; + +BEGIN { + use Test::More; + eval "use Type::Tiny 1.000005; 1" || do { + plan skip_all => "Trouble loading Type::Tiny and friends => $@"; + }; +} + +BEGIN { + package MyApp::Types; + $INC{'MyApp/Types.pm'} = __FILE__; + + use strict; + use warnings; + + use Type::Utils -all; + use Types::Standard -types; + use Type::Library + -base, + -declare => qw( UserId Heart ); + + extends "Types::Standard"; + + declare UserId, + as Int, + where { $_ < 5 }; + + declare Heart, + as Str, + where { $_ eq '♥' }; + +} + +{ + package MyApp::Controller::Root; + $INC{'MyApp/Controller/Root.pm'} = __FILE__; + + use Moose; + use MooseX::MethodAttributes; + use MyApp::Types qw/Tuple Int Str StrMatch ArrayRef Enum UserId Heart/; + + extends 'Catalyst::Controller'; + + sub user :Local Args(1) + Query(page=>Int,user=>Tuple[Enum['a','b'],Int]) { + my ($self, $c, $int) = @_; + $c->res->body("page ${\$c->req->query_parameters->{page}}, user ${\$c->req->query_parameters->{user}[1]}"); + } + + sub default :Default { + my ($self, $c, $int) = @_; + $c->res->body('default'); + } + + MyApp::Controller::Root->config(namespace=>''); + + package MyApp; + use Catalyst; + + MyApp->setup; +} + +use Catalyst::Test 'MyApp'; + +{ + my $res = request '/user/1?page=10&user=a&user=100'; + is $res->content, 'page 10, user 100'; +} + +done_testing;