From: Karen Etheridge Date: Sat, 12 Jun 2010 01:16:00 +0000 (-0700) Subject: Redefine RunnableClass in terms of Params::Util::_CLASS X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=1924178262e396bcb9cb649a894ca31647e9c231;p=gitmo%2FMooseX-Runnable.git Redefine RunnableClass in terms of Params::Util::_CLASS resolves https://rt.cpan.org/Public/Bug/Display.html?id=58028 --- diff --git a/Changes b/Changes index 7784247..eb5981b 100644 --- a/Changes +++ b/Changes @@ -1,3 +1,7 @@ +0.02_01 Fri Jun 11 18:12:26 PDT 2010 + - modified verification of RunnableClass values to use + Params::Util::_CLASS (Karen Etheridge) + 0.02 Mon Nov 2 02:30:10 CST 2009 - fix bug where roles of superclasses were not considered when applying invocation schemes. diff --git a/Makefile.PL b/Makefile.PL index d8706a1..389ea8a 100644 --- a/Makefile.PL +++ b/Makefile.PL @@ -9,6 +9,7 @@ requires 'MooseX::Types' => '0.10'; requires 'MooseX::Types::Path::Class'; requires 'namespace::autoclean'; requires 'List::MoreUtils'; +requires 'Params::Util'; build_requires 'Test::More'; build_requires 'ok'; diff --git a/lib/MooseX/Runnable/Invocation.pm b/lib/MooseX/Runnable/Invocation.pm index 3ebc1b1..b21617c 100644 --- a/lib/MooseX/Runnable/Invocation.pm +++ b/lib/MooseX/Runnable/Invocation.pm @@ -3,6 +3,7 @@ use Moose; use MooseX::Types -declare => ['RunnableClass']; use MooseX::Types::Moose qw(Str HashRef ArrayRef); use List::MoreUtils qw(uniq); +use Params::Util qw(_CLASS); use namespace::autoclean; require Class::MOP; @@ -12,7 +13,7 @@ require Class::MOP; subtype RunnableClass, as Str, - where { $_ =~ /^[:A-Za-z_]+$/ }; + where { _CLASS($_) }; with 'MooseX::Runnable'; # this class technically follows diff --git a/t/basic-mx-getopt.t b/t/basic-mx-getopt.t index 6bafdb9..a1dda47 100644 --- a/t/basic-mx-getopt.t +++ b/t/basic-mx-getopt.t @@ -1,7 +1,7 @@ use strict; use warnings; use Test::Exception; -use Test::More tests => 5; +use Test::More tests => 9; use MooseX::Runnable::Invocation; use ok 'MooseX::Runnable::Invocation::Scheme::MooseX::Getopt'; @@ -25,17 +25,27 @@ my $foo; } } -my $invocation = MooseX::Runnable::Invocation->new( - class => 'Class', -); +{ package Class2; + use Moose; + extends 'Class'; +} + +foreach my $class (qw(Class Class2)) +{ + my $invocation = MooseX::Runnable::Invocation->new( + class => $class, + ); -ok $invocation; + ok $invocation, 'class is instantiatable'; -my $code; -lives_ok { - $code = $invocation->run('--foo', '42', 0); -} 'run lived'; + my $code; + lives_ok { + $code = $invocation->run('--foo', '42', 0); + } 'run lived'; + + is $foo, '42', 'got foo from cmdline'; + + is $code, 0, 'exit status ok'; +} -is $foo, '42', 'got foo from cmdline'; -is $code, 0, 'exit status ok';