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