mention the aliasing feature of NoGetopt as well
[gitmo/MooseX-Getopt.git] / t / 100_gld_default_bug.t
CommitLineData
630657d5 1use strict;
2use warnings;
3
9fbb5be9 4use Test::More tests => 6;
5use Test::NoWarnings 1.04 ':early';
630657d5 6
6a378fbd 7use Test::Requires {
8 'Getopt::Long::Descriptive' => 0.01, # skip all if not installed
9};
10
11use_ok('MooseX::Getopt');
630657d5 12
13{
14 package Engine::Foo;
15 use Moose;
2557b526 16
630657d5 17 with 'MooseX::Getopt';
2557b526 18
630657d5 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