6 use Test::More tests => 6;
9 use_ok('MooseX::Getopt');
15 use Moose::Util::TypeConstraints;
17 use Scalar::Util 'looks_like_number';
19 with 'MooseX::Getopt';
23 => where { scalar (grep { looks_like_number($_) } @$_) };
25 MooseX::Getopt::OptionTypeMap->add_option_type_to_map(
26 'ArrayOfInts' => '=i@'
32 default => sub { [0] }
40 my $app = App->new_with_options;
43 is_deeply($app->nums, [0], '... nums is [0] as expected');
47 local @ARGV = ('--nums', 3, '--nums', 5);
49 my $app = App->new_with_options;
52 is_deeply($app->nums, [3, 5], '... nums is [3, 5] as expected');
55 # Make sure it really used our =i@, instead of falling back
56 # to =s@ via the type system, and test that exceptions work
59 local @ARGV = ('--nums', 3, '--nums', 'foo');
61 my $app = App->new_with_options;
63 like($@, qr/Value "foo" invalid/, 'Numeric constraint enforced');