use warnings tester with fewer dependencies, issues
[gitmo/MooseX-Getopt.git] / t / 003_inferred_option_type.t
1 use strict;
2 use warnings FATAL => 'all';
3
4 use Test::More tests => 6;
5 use Test::Warnings;
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     local @ARGV = ();
33
34     my $app = App->new_with_options;
35     isa_ok($app, 'App');
36
37     is_deeply($app->nums, [0], '... nums is [0] as expected');
38 }
39
40 {
41     local @ARGV = ('--nums', 3, '--nums', 5);
42
43     my $app = App->new_with_options;
44     isa_ok($app, 'App');
45
46     is_deeply($app->nums, [3, 5], '... nums is [3, 5] as expected');
47 }
48