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