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