4 use Test::More tests => 6;
7 use_ok('MooseX::Getopt');
13 use Moose::Util::TypeConstraints;
15 use Scalar::Util 'looks_like_number';
17 with 'MooseX::Getopt';
21 => where { scalar (grep { looks_like_number($_) } @$_) };
23 MooseX::Getopt::OptionTypeMap->add_option_type_to_map(
24 'ArrayOfInts' => '=i@'
30 default => sub { [0] }
38 my $app = App->new_with_options;
41 is_deeply($app->nums, [0], '... nums is [0] as expected');
45 local @ARGV = ('--nums', 3, '--nums', 5);
47 my $app = App->new_with_options;
50 is_deeply($app->nums, [3, 5], '... nums is [3, 5] as expected');
53 # Make sure it really used our =i@, instead of falling back
54 # to =s@ via the type system, and test that exceptions work
57 local @ARGV = ('--nums', 3, '--nums', 'foo');
59 my $app = App->new_with_options;
61 like($@, qr/Value "foo" invalid/, 'Numeric constraint enforced');