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