test for warnings everywhere
[gitmo/MooseX-Getopt.git] / t / 003_inferred_option_type.t
CommitLineData
f63e6310 1use strict;
2use warnings;
3
9fbb5be9 4use Test::More tests => 6;
5use Test::NoWarnings 1.04 ':early';
f63e6310 6
7BEGIN {
8 use_ok('MooseX::Getopt');
9}
10
11{
12 package App;
13 use Moose;
14 use Moose::Util::TypeConstraints;
2557b526 15
f63e6310 16 use Scalar::Util 'looks_like_number';
2557b526 17
f63e6310 18 with 'MooseX::Getopt';
19
20 subtype 'ArrayOfInts'
21 => as 'ArrayRef'
22 => where { scalar (grep { looks_like_number($_) } @$_) };
2557b526 23
f63e6310 24 has 'nums' => (
25 is => 'ro',
26 isa => 'ArrayOfInts',
27 default => sub { [0] }
2557b526 28 );
29
f63e6310 30}
31
32{
33 local @ARGV = ();
34
35 my $app = App->new_with_options;
36 isa_ok($app, 'App');
2557b526 37
38 is_deeply($app->nums, [0], '... nums is [0] as expected');
f63e6310 39}
40
41{
42 local @ARGV = ('--nums', 3, '--nums', 5);
43
44 my $app = App->new_with_options;
45 isa_ok($app, 'App');
2557b526 46
47 is_deeply($app->nums, [3, 5], '... nums is [3, 5] as expected');
f63e6310 48}
49