Commit | Line | Data |
630657d5 |
1 | use strict; |
2 | use warnings; |
3 | |
9fbb5be9 |
4 | use Test::More tests => 6; |
5 | use Test::NoWarnings 1.04 ':early'; |
630657d5 |
6 | |
12f4bf75 |
7 | use Getopt::Long::Descriptive; |
6a378fbd |
8 | |
9 | use_ok('MooseX::Getopt'); |
630657d5 |
10 | |
11 | { |
12 | package Engine::Foo; |
13 | use Moose; |
2557b526 |
14 | |
630657d5 |
15 | with 'MooseX::Getopt'; |
2557b526 |
16 | |
630657d5 |
17 | has 'nproc' => ( |
195fb408 |
18 | traits => ['Getopt'], |
630657d5 |
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 | |