test for warnings everywhere
[gitmo/MooseX-Getopt.git] / t / 100_gld_default_bug.t
1 use strict;
2 use warnings;
3
4 use Test::More tests => 6;
5 use Test::NoWarnings 1.04 ':early';
6
7 use Test::Requires {
8     'Getopt::Long::Descriptive' => 0.01, # skip all if not installed
9 };
10
11 use_ok('MooseX::Getopt');
12
13 {
14     package Engine::Foo;
15     use Moose;
16
17     with 'MooseX::Getopt';
18
19     has 'nproc' => (
20         metaclass   => 'Getopt',
21         is          => 'ro',
22         isa         => 'Int',
23         default     => sub { 1 },
24         cmd_aliases => 'n',
25     );
26 }
27
28 @ARGV = ();
29
30 {
31     my $foo = Engine::Foo->new_with_options(nproc => 10);
32     isa_ok($foo, 'Engine::Foo');
33
34     is($foo->nproc, 10, '... got the right value (10), not the default (1)');
35 }
36
37 {
38     my $foo = Engine::Foo->new_with_options();
39     isa_ok($foo, 'Engine::Foo');
40
41     is($foo->nproc, 1, '... got the right value (1), without GLD needing to handle defaults');
42 }
43
44
45